Interstellar 2.0
JensRavens opened this issue · 18 comments
This issue is collecting all feature requests that require a breaking change to the public API of this library. Please discuss features in the corresponding issues (linked in the description):
- Split up
Signal<T>
andResult<T>
. This also adds support for non-failing signals and fixes the naming of some methods (flatMap
becomesthen
, soflatMap
is free to do a real flat-mapping). #15 - Support
Signal<Void>
. This might require to get rid of sending the initial signal value on subscribe. #13 - Add a way to unsubscribe from a signal using a subscribtion-object. #12
Hi
Congratulations on the library. Interstellar looks great! Could you say more than less when do you plan to release v. 2.0 ?
Great, it sounds good,
I am mostly interested in #12 but all chances are very welcome.
@JensRavens Do you have any ideas or specifics on how one could contribute to v2? I see there's a branch and I'm wondering what next steps the community could help you take – we're happy to help with such a useful library!
Hey Ash,
nice to see you here! I've been pretty much heads down in ruby over the last few weeks, but I'll have some more time for Swift now.
Currently I hope to get some feedback over the design decisions of v2. Dropping Signal in favor of Observable is a needed, but rather drastically.
Also I'm really unsure how to handle Observables on subscribe and if they should keep notifying the observer on subscribe. This is helpful in most circumstances but can possible introduce unintentional memory leaks. Making that optional could possible make the whole thing pretty bloated (and the main advantage of this library is it's small size and easy usage). Same for unsubscribing.
So mostly I'm looking for a wishlist of features from the library's users how Interstellar should work in the next version.
@JensRavens Would you consider adding UI Bindings in a separate, dependent project (InterstellarUI for example) so that those among us who'd like to subscribe to events from UITextFields, UIButtons etc. are able to do so?
Yep. My first reflex was to add it as a cocoapods subspec. But as I'm planning to use Interstellar also on Server Side Linux apps, it might be best to move it out of the core (there's already a divide between Interstellar Core and the Warpdrive extensions).
@JensRavens Cool, I'll take a look at the v2 branch and provide some feedback – does here work? For code-level feedback, a PR from that branch into master makes sense, but it might be early for that. Do you consider the v2 branch at all ready for testing in production?
For UI bindings, I think moving to another repo makes sense. RxSwift has RxCocoa as a second podspec in the repo, and it works okay for them (but I think it's a little messy). Totally a personal preference though.
@ashfurrow It's should be pretty stable, but expect some changes during the next weeks (making the subscribers subclasses of an abstract base class is not what I would like to do in the long term, but that shouldn't affect the public api).
For the UI-bindings: I've already came up with a nice name: Holodeck (which completes Interstellar and Warpdrive).
@JensRavens Holodeck is a cool name, I like it :)
Keep us posted when you create this project. I have a couple of UI bindings I'll submit then. And I'll try to have a look at the v2 branch when I get some free time.
@JensRavens care to elaborate a bit more on:
Also I'm really unsure how to handle Observables on subscribe and if they should keep notifying the observer on subscribe
Love the simplicity of Interstellar over RAC/RxSwift.
@JensRavens Could you comment on following suggestions/questions ?
- What do you think about adding "Unsubscribable" protocol with unsubscribe method and then make ObserverToken implement it ? It may simplify storing tokens in Array (e.g [Unsubscribable]). Currently I don't have "nice" solution for that.
- You mentioned that you are thinking about depreciation of Signal. Are there any plans to add similar set of functions from Signal to Observable ? Currently I am migrating to v2. and noticed lack of e.g merge or few versions of flatMap.
@anaglik
For the token part:
ObserverToken
currently is a class and the only class that can be returned by the subscribe method. What would be the advantage of having it as a protocol? [ObserverToken<String>]
looks fine to me.
Observables by now should support everything that was supported by signal - and more (merging is currently discussed in #39). The old version of flatmap
was never a real flatmap
, therefore it has been renamed to then
to show the similarities to javascript's promises. It's not directly implemented on observable, but as an extension of Observable<Result<T>>
.
- In my case I would like to store ObserverTokens of different types in one array (something like
[ObserverTokens<Any>]
). I could't find elegant way to do that without protocol. - You are absolutely right about old version of
flatMap
. Nonetheless, I couldn't find good replacement forflatMap<U>(f: (T, (Result<U>->Void))->Void) -> Signal<U>
but I will definitely look atthen
.
Thanks for quick reply!
I've had this situation too, where I want an array of indiscriminate observer tokens to unsubscribe from later.
Here's a short update: v2 is now fully tested and documented and I think it's ready for production (I think @ashfurrow is already using it). If there are no objections I'll release it just in time on friday for my Interstellar workshop in Zürich.
Here's a the list of awesome new stuff:
Signal<T>
was split up intoObservable<T>
which can contain (but doesn't have to) aResult<T>
.Observable<Result<T>>
get's some superpowers due to protocol extensions which replaces theflatmap
function (now calledthen
) (#15).- There's a new way to manually unsubscribe from an
Observable<T>
(#40). - Warpdrive has been ported to Linux thanks to the release of the
Dispatch
library. - BYOR™-Technology (Bring Your Own Resulttype) allows you to use
Result<T>
s from other libraries or your own code as long as they conform to the newResultType
protocol. Observable<T>
does have options to configure its updating behaviour:.NoInitialValue
does not save the current value and therefore allowsVoid
-values (#13).Once
will call subscribers exactly once and then automatically unsubscribe them (effectively making it aPromise<T>
and fixing a lot of retain cycles)
@JensRavens When do you plan to move v2 into master?