Comments (11)
Is there going to be a method to get a subscribable from a sequence?
I'm using rac_toSubscribable
to work with arrays of subscribables by converting them to subscribables of subscribables and then back to arrays.
from reactivecocoa.
There's not really a sane way to do that, given that sequences are meant to be used lazily. I would recommend instead setting up APIs to use <RACStream>
and not care about the specific stream type.
from reactivecocoa.
Though you can't really use subscribables and sequences interchangeably since the accessing is different.
from reactivecocoa.
@Coneko Is there any reason not to use a sequence of subscribables for the case you describe?
from reactivecocoa.
I can't -flattenMap:
a sequence of subscribables, but I guess I could always use -map:
on the sequence and then call +merge:
with the resulting array.
Although +merge:
itself is implemented through -rac_toSubscribable
and -flatten
.
Is that going to go too? I use that quite a bit as well.
from reactivecocoa.
Maybe the right answer here is to move -first
, -array
, etc. into <RACStream>
proper, so that values can be retrieved from streams in a generic way.
from reactivecocoa.
It doesn't really relate to those in my case.
I use +merge:
when I want to subscribe with the same subscriber to multiple subscribables. For example several NSNotificationCenter
notifications, where the selective logic is dependent on the properties of the notification rather than the source of it.
I use -rac_toSubscribable
followed by -flatten
when I have arrays of asynchronous tasks, or of objects on which I have to execute asynchronous tasks. The interface for those are subscribables that send a next with the result of the computation, or just error or completed if the task is a side effect.
So basically it goes array of objects
-> -rac_toSubscribable
-> subscribable of objects
-> -map:
, -filter:
, etc -> subscribable of tasks
-> -flatten
, -catch:
, etc -> subscribable of results
-> -toArray
, -finally:
, -subscribeCompleted:
, etc -> array of results
. I actually don't use toArray
because it deadlocks in most of those cases, but I use something equivalent.
I find it pretty handy, but I guess it doesn't really fit in the subscribables are a push-based stream of values view.
from reactivecocoa.
I'll add sequence <-> subscribable conversion methods to #92, I think, and then still remove rac_toSubscribable
from NSObject
. That seems to be the best way forward, since it discourages turning arrays into subscribables, but still provides a way to do it.
from reactivecocoa.
Works for me. I'll probably start using sequences in many places where I'm using arrays now once that one goes through anyway.
from reactivecocoa.
Why converting an array to a subscribable instead of a sequence should be discouraged?
Aren't those to be seen as two different instances of the RACStream
monad that you can pick an choose depending on your needs?
As @Coneko is saying, building subscribables starting form an array is a pretty common task in here.
from reactivecocoa.
@thenikso Sequences form a better abstraction for arbitrary computation, while subscribables are better for asynchronous or reactive streams of values.
It's not that arrays shouldn't be used as subscribables — simply that sequences make more sense for most such cases, and so should be the default.
from reactivecocoa.
Related Issues (20)
- [SwiftPM on Xcode] Package resolution failed HOT 2
- Unable to compile targeting macOS Catalyst using SwiftPM (fix exists)
- why RACObserve(self.scoreStepper,value) not available? HOT 1
- App rejected for HealthKit metadata HOT 4
- UISearchBar delegate proxy crash on Mac Catalyst HOT 1
- Build error when using ReactiveCocoa via Swift Package Manager HOT 3
- can not deinit HOT 2
- Xcode12 ReactiveObj archive error HOT 3
- How to implement PIN input with attempts HOT 1
- Dispose SignalProducer created via Action HOT 1
- UnsafeKVOProperty initializer crashes after updating to ReactiveSwift 6.5.0 HOT 1
- EXC_BAD_ACCESS Cash with NSURL HOT 1
- ReactiveCocoa 11.1.0 incompatible with ReactiveSwift 6.6.0 HOT 5
- Xcode 12.5 beta 3 can't build ReactiveCocoa with SwiftPM. HOT 2
- Using "<~" binding function with Signal.Observers causes memory leaks. HOT 1
- Upgrading from very old version (2.5) fails - can't find ReactiveCocoa.h HOT 1
- Cannot remove an observer <RACKVOProxy 0x280264940> for the key path "unit" from <HGConfigureModel 0x280d25050> because it is not registered as an observer.
- Current version can't be compiled with the latest ReactiveSwift version HOT 2
- Current version can't be compiled with the latest ReactiveSwift version HOT 6
- Add output values support for interception
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reactivecocoa.