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

Require Signals to get wrapped in a Worker #1025

Closed
wants to merge 8 commits into from

Conversation

AquaGeek
Copy link
Contributor

This should address #402. The aesthetics of the SignalWorker are very much open for feedback. We could also leave context.subscribe in place and create the worker in the infrastructure layer instead.

@AquaGeek AquaGeek added the swift Affects the Swift library. label Mar 13, 2020
@AquaGeek AquaGeek changed the title Require Signals to get wrapped in a Worker Require Signals to get wrapped in a Worker Mar 16, 2020
@AquaGeek AquaGeek force-pushed the stromberg/wrap-signals-in-worker branch from 590e677 to 90178f3 Compare March 19, 2020 19:50
Copy link
Contributor

@JustinDSN JustinDSN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI checks are failing

Copy link
Collaborator

@zach-klippenstein zach-klippenstein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you consider making SignalWorker abstract and having its own run() method that returns a Signal, mirroring Worker? Seems odd that the api for creating Signal workers vs SignalProducer workers is different, although I'm sure there's a good reason (I'm just curious what it is).

@AquaGeek
Copy link
Contributor Author

Did you consider making SignalWorker abstract and having its own run() method that returns a Signal, mirroring Worker? Seems odd that the api for creating Signal workers vs SignalProducer workers is different, although I'm sure there's a good reason (I'm just curious what it is).

I'm not entirely sure I follow what you're suggesting. SignalWorker is a convenience wrapper — for SignalProducer Workers we currently require you to define them yourself. With Signals I don't think it makes sense to define your own Worker type — it's a hot signal.

This causes test failures due to unexpected Workers getting encountered.
Instead, subscribe to the signal like we used to in `subscribe()`.
@AquaGeek AquaGeek force-pushed the stromberg/wrap-signals-in-worker branch from 90178f3 to 220e9d8 Compare March 25, 2020 18:43
@JustinDSN JustinDSN requested a review from amorde March 25, 2020 18:46
@@ -270,16 +270,14 @@ fileprivate final class RenderTestContext<T: Workflow>: RenderContextType {
let sink = Sink<Action> { action in
observer.send(value: AnyWorkflowAction(action))
}
subscribe(signal: signal)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because subscribe has been removed I moved its logic up into this function and am subscribing directly — i.e. I'm not wrapping the Signal here in a worker (it creates test failures due to unexpected workers being encountered).

@zach-klippenstein
Copy link
Collaborator

I don't see what the temperature of the stream has to do with it. Making it an extendable type means implementors can implement isEquivalent, vs passing in a key. That's the only real difference that I can tell.

}

public func isEquivalent(to otherWorker: SignalWorker) -> Bool {
return key == otherWorker.key
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bencochran Is Key comparison enough here? Do we run into the "need consumers to understand that Key needs to be differentiated enough" problem?

@AquaGeek
Copy link
Contributor Author

We're going to split this PR into two:

  • Introduce the SignalWorker
  • Remove the subscribe function from the RenderContext

That way, we can land the first, integrate it (incrementally), and fix any issues that come out of that.

@AquaGeek AquaGeek closed this Mar 27, 2020
@JustinDSN
Copy link
Contributor

Sounds great, incremental is better and less painful!

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

Successfully merging this pull request may close these issues.

None yet

5 participants