Closed note89 closed 7 years ago
guess the type signature need to update then ? and the readme where it says
import { fromEvent } from 'most'
import { hold } from '@most/hold'
// start holding on first subscription
const clickStream = fromEvent('click', document)
.map(e => ({ x: e.clientX, y: clientY }))
.thru(hold)
// hold the latest event even before the first subscription
clickStream.drain();
Given an input stream:
stream: -a---b---c---d->
observers which begin observing at different times will see:
observer1: -a---b---c---d->
observer2: a-b---c---d->
observer3: c--d->
The example will not work anymore right ?
Hey @note89 You're right about the example. Sorry about that. It needs to be updated to show @most/core
usage. I'll fix that.
However, the type signature is correct. The intent is that hold
returns a Stream, of which one implementation happens to be MulticastSource, such that callers should depend only on the Stream interface, and not on the implementation details of MulticastSource.
but hold
now returns a Source
so i get runtime error when I follow the type signature provided
https://github.com/mostjs/hold/blob/master/type-definitions/hold.d.ts
export function hold<A>(stream: Stream<A>): Stream<A>;
Hmmm, ok. Could you paste the error and example code that produces it? Thanks!
sorry, my bad didn't realize @most/core
is a replacement for most
.
thought it was something most used underneath. so i used @most/hold
3.0.0 with most
Is most depricated now?
Thank you very much for the information!
Hey @note89 no worries at all. Sorry for the confusion. I'll try to clarify the relationship.
Most 1.x is not deprecated. It will continue to be fully supported until most 2.0 is released.
@most/core
is a reimplementation of most's architecture using the lessons we learned from building and maintaining most. It intentionally has a smaller API that is more tailored to a functional style of programming. Most 2.0 will be implemented on top of @most/core
.
If you're starting a new project, and @most/core
's leaner API, it's programming style seems interesting, and you can tolerate the possibility of small changes before it becomes 1.0, I recommend starting with it rather than most.
I hope that helps! I opened an issue to add this question to a @most/core
FAQ.
Thank you very much :) Love most.js use it every day! Hugh thanks for creating such an awesome thing !
Thanks, @note89. Glad to hear it's been useful for you :+1:
https://github.com/mostjs/hold/blob/3ae8107c4974a0c7c40dc8194c8bdf3dbdd45737/src/index.js#L5-L7
Hold returns a
MulticastSource
and not aStream
like before — is this the intended behavior ?The change was made in #22 Cheers!