RxFeedback.swift icon indicating copy to clipboard operation
RxFeedback.swift copied to clipboard

[Proposal] React for Void?

Open domasn opened this issue 5 years ago • 0 comments

Hi there 👋

My company struggled a bit after 2.0 removed react for non-equatable types. I think, it's absolutely reasonable to to require types returned by request be equatable.

Though, we are using Void? in quite a few places to trigger feedback loops that don't require any parameters. Examples include anything from networking to navigation, from current location fetch to database sync.

We ended up writting a custom react just for this case:

func react<State, Event>(request: @escaping (State) -> Void?,
	                 effects: @escaping () -> Signal<Event>) -> (Driver<State>) -> Signal<Event> {
    return react(request: { request($0) != nil ? true : nil }, // Bool to the rescue 🙈
                 effects: { _ in effects() })
}

Do you think it would make sense to add a react for Void? to RxFeedback? Have you encountered this?

Thanks!

domasn avatar May 29 '19 12:05 domasn