Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor createStore to remove StateStream usage #4

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

agentk
Copy link
Member

@agentk agentk commented Dec 27, 2015

The RxSwift Store now uses the original code again:

subjectDispatcher
.scan(initalState, accumulator: reducer)
.startWith(initalState)
.subscribe(stateSubject)

The setupStoreBacking function returns a tuple of the dispatch sink, state subject and createStore function. It can be used to expose the underlying dispatch and subject for direct usage inside an app.

It's useful for subscribing to nested properties. Ie:

let factory = setupStoreBacking()

let store = applyMiddleware([
    observableMiddleware
    ])(factory.createStore)(reducer, state)

factory.subject.map { $0.auth.loggedIn && $0.auth.tokenExpired }.onNext { tokenExpired in
    // Do something when a state is emitted where the user is logged in and the token is expired
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant