Giter Site home page Giter Site logo

rxtodo's Introduction

RxTodo

Swift Build Status

RxTodo is an iOS application developed using ReactorKit. This project is for whom having trouble with learning how to build a RxSwift application due to lack of references. (as I did ๐Ÿ˜›)

Features

  • Using ReactorKit
  • Using RxDataSources
  • Observing model create/update/delete across the view controllers
  • Navigating between view controllers
  • Immutable models
  • Testing with RxExpect

Architecture

reactorkit

Visit ReactorKit for detail.

Requirements

  • iOS 8+
  • Swift 3
  • CocoaPods

Screenshots

rxtodo

Contribution

Discussion and pull requests are welcomed ๐Ÿ’–

License

RxTodo is under MIT license. See the LICENSE for more info.

rxtodo's People

Contributors

cruisediary avatar devolaw avatar devxoul avatar geonu avatar pierrebrisorgueil avatar wanbok avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rxtodo's Issues

Cell State bind and distinctUntilChanged problem

Hello @devxoul , I have a problem that I can not understand.

In a collection or table when updating a cell I get the impression that all states are bind again for all cells, regardless of whether it is distinctUntilChanged or not.

To illustrate the problem in this example, simply edit TaskCell.swift

switch : self.titleLabel.text = reactor.currentState.title

to:

 reactor.state
        .map { $0.title }
        .distinctUntilChanged()
        .map { result in
            print("test")
            return result
        }
        .bind(to: self.titleLabel.rx.text)
        .disposed(by: self.disposeBag)

when you will check or not reactor.currentState.isDone, you will see three print of "test".
yet they have not changed, and only the isDone has been changed.

could someone explain to me? maybe I misunderstood how distinctUntilChanged works

View doesn't know what ViewModel does.

Thanks for the excellent project, I've been studying your code and trying to implement it on my own learning project

would like your opinion on this:
View doesn't know what ViewModel does. View can only communicate to ViewModel about what View did.

I have mixed feelings regarding this.

For example
How is the first code (implemented using your suggestion) more readable than the second code?

mailLoginButtonTaps.asObservable()
    .withLatestFrom(Observable.combineLatest(email.asObservable(), password.asObservable()) { ($0, $1) }) .flatMapLatest({ (email, password) in
        return authenticationService.login(withEmail: email, password: password)
            .trackActivity(activityIndicator)
      })
    .asDriver(onErrorJustReturn: false)

viewModel.emailLogin()

func emailLogin() -> Driver<LoginResult> {
    return authenticationService.login(withEmail: email.value, password: password.value)
            .trackActivity(activityIndicator)
}

Memory Leak?

Hi, So Im following RxSwift examples. The author has mentioned to use

    _ = Observable<Int>.interval(1, scheduler: MainScheduler.instance)
        .subscribe(onNext: { _ in
            print("Resource count \(RxSwift.Resources.total)")
        })

in the AppDelegate to track the resources allocation and deallocation.

After observing the same on your RxTodo app. When you display the AddTask-ViewController and dismiss it. There is always some amount of resources which are not deallocated and the resource count keeps growing each time we open the view controller. I was wondering if you have any thoughts on fixing it. I tried adding many items to the dispose bag but doesn't seem to do the trick.

edit mode : state initialisation not sync with input text

Hello,

just a little trouble I met, from the code I saw :

TaskEditViewReactor.swift

  init(provider: ServiceProviderType, mode: TaskEditViewMode) {
    self.provider = provider
    self.mode = mode

    switch mode {
    case .new:
      self.initialState = State(title: "New", taskTitle: "", canSubmit: false)
    case .edit(let task):
      self.initialState = State(title: "Edit", taskTitle: task.title, canSubmit: true)
      print("test 0 \(self.initialState)")
    }
  }

TaskEditViewController

    reactor.state.asObservable().map { $0.taskTitle }
      .distinctUntilChanged()
      .bind(to: self.titleInput.rx.text)
      .disposed(by: self.disposeBag)

I think the goal was to open the new view in edit mode with the input initiated with the text of the task to modify ?

if I understood everything, it's a bug, the input is empty in edit mode, I had the same problem on my side, I fixed it quickly by the initialization of the controller but I am sure that there is better to do.

Can't run pod install

Get the following error message when I run pod install:

Unable to find a specification for ReusableKit (= 0.3.0)

Mutate Action to Observable<Mutation>

Hi, @devxoul and thanks for great project. I have a question regarding TaskListViewReactor and TaskService structure. We have func mutate(taskEvent: TaskEvent) -> Observable<Mutation> which reacts to var event: PublishSubject<TaskEvent> { get } from TaskServiceType.
Why should we have this variable and emit events in every method (so it is side-effect)? I see, that we subscribed in reactor and merge this event and common Mutation. But we can have kind of this method

private func mutateMarkIsDone(task: Task) -> Observable<Mutation> {
        return self.provider.taskService.markAsDone(taskID: task.id).flatMap { task -> Observable<Mutation> in
            let state = self.currentState
            guard let indexPath = self.indexPath(forTaskID: task.id, from: state) else { return .empty() }
            var task = state.sections[indexPath].currentState
            task.isDone = true
            let reactor = TaskCellReactor(task: task)
            return .just(.updateSectionItem(indexPath, reactor))
        }
    }

and remove event var from TaskServiceType, remove transform(mutation: Observable<Mutation>) -> Observable<Mutation> and func mutate(taskEvent: TaskEvent) -> Observable<Mutation>. Or maybe I missed some important logic?

Why TaskListViewModel is dealloc?

I found TaskListViewController dose not own ViewModel. The TaskListViewModel instance will dealloc soon after TaskListViewModel has inited. Can someone explain it?

Not work

When tap the done button,there is nothing happen

Multiple Sections

Can you show how to add multiple sections using ReactorKit & RxDataSource?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.