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

Propagate events with state for feedbacks #12

Merged
merged 4 commits into from
Jul 13, 2020

Conversation

sergdort
Copy link
Contributor

Per #5

Resurrecting old proposal from @inamiy babylonhealth/ReactiveFeedback#41

This is an additive change to add Optional<Event> argument in Feedback so that unnecessary intermediate states will no longer be required.

Event-driven feedback will be useful for following scenarios, without needing to add a new state and then transit (and transit back again):

  • Logging
  • Analytics
  • Routing
  • Image loader (but not managing its internal states)

This is a change from Moore model to (kind of) Mealy model as discussed in babylonhealth/ReactiveFeedback#32 (review) .

Please note that reducer and feedback are still in sequence, not parallel.

Also, please note that Optional<Event> is used here as a workaround since it requires more breaking changes to minimize into non-optional Event.

@sergdort sergdort requested review from andersio and RuiAAPeres May 27, 2020 10:26
@sergdort sergdort self-assigned this May 27, 2020
@sergdort sergdort added the enhancement New feature or request label May 27, 2020
@sergdort sergdort changed the title Propagate even with state for feedbacks Propagate events with state for feedbacks May 27, 2020
@andersio
Copy link
Member

Could you add unit tests to assert that events are flowing in the order as expected?

@sergdort sergdort force-pushed the sergey/feedbacks-with-events branch from ce2dd4a to 92f4baa Compare June 2, 2020 14:17
@sergdort
Copy link
Contributor Author

sergdort commented Jun 2, 2020

@andersio I believe I addressed your comments

@andersio
Copy link
Member

andersio commented Jun 11, 2020

@sergdort

We need to test this:

public init(
events: @escaping (
_ state: SignalProducer<(State, Event?), Never>,
_ output: FeedbackEventConsumer<Event>
) -> SignalProducer<Never, Never>
) {

that subscribing to state (p.s. need renaming?) does yield nil and subsequent events in the order we expected them to be.

@andersio andersio merged commit 49f8a95 into develop Jul 13, 2020
@andersio andersio deleted the sergey/feedbacks-with-events branch July 13, 2020 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants