-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Mapping RAC2 hot signals to RAC3 Signal #1930
Comments
|
I had a similar question. It seems like the signals from UI controls should be "hot" or a |
|
Interesting, I've just read that thread. I'm glad that @neilpa is in agreement that signals emitted by UI Controls are 'hot' and hence should be modelled as a 'Signal'. However, as you mentioned there are quite a few operations that can be applied to SignalProducers that I would naturally want to apply to signals. For example I went down a similar route, implementing a few extra operations on Signal, but then switched to using SwignalProducer which has the whole 'vocabulary' available to it. |
You can't, but this should be less of an issue once the UIKit/AppKit extensions are updated to use the new APIs directly. That work hasn't happened yet because the new API was in-flux until recently.
The equivalent of this for hot
Generally you'll want to use an |
|
Thanks for the feedback. I'm familiar with the general concept of commands. Although with the example I am considering I don't feel that they are appropriate. As an example, I have a text field where I want to provide suggestions as the user types. This requires an API request. To my mind, the text input becomes a signal, which is throttled then flatMapped with a signal producer that represents the API request. Personally I don't feel that actions / commands are the correct model for a text field's text. |
This is what I'm suggesting too where |
|
@ColinEberhardt How would you convert the Which fails with Any ideas on how to implement this? I know you can't instantiate a |
|
@OscarSwanros How about the following: |
|
It did work, thanks! |
|
@OscarSwanros rather than cast to |
|
Yes, that's what I ended up doing. |
|
I like @neilpa's suggestion above:
This doesn't really cause problems in the same way that |
And even for signal-of-signals, |
|
@neilpa Since |
|
I was thinking about pre- |
|
@jspahrsummers I opened #1967 to continue this discussion. |
|
#1966 was reverted because of bugs. Gonna reopen this so we can track it as an enhancement. |
I'm trying to map between RAC2 and RAC3 concepts, most of which seem to make sense. The one that I am struggling with is the mapping of hot signals.
The ObjC Bridging API allows you to construct a SignalProducer from a RACSignal, however it does not have an API method for constructing a Signal from a RACSignal.
As a result, any RAC2 signal is bridged to a SignalProducer and as such becomes a cold signal. Personally I consider signals derived from UI control to be hot, however I know that this is debatable.
This doesn't stop me getting the job done, I can certainly construct a SignalProducer in this case:
And this works just fine for my purposes, but it does still leave me wondering how to bridge hot signals from RACSignal to Signal?
The text was updated successfully, but these errors were encountered: