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

Properties #171

Closed
iofjuupasli opened this issue Dec 2, 2015 · 6 comments
Closed

Properties #171

iofjuupasli opened this issue Dec 2, 2015 · 6 comments

Comments

@iofjuupasli
Copy link

@briancavalier
Copy link
Member

Hi @iofjuupasli! Most.js's goal is efficient discrete events. It doesn't have a notion of a continuously-valued component, like Properties / Behaviors / Signals. The two concepts are complimentary, so I can imagine another package that provides a continuous component.

@iofjuupasli
Copy link
Author

Can you please give a hint how to do it?

function toProperty(stream){
    var lastValue;
    return function(){
        return stream
            .tap(function (v) {
                lastValue = v;
            })
            .startWith(lastValue);
    };
}

then

var origStream = most.periodic(100, true);
var prop = toProperty(origStream);
prop().map()...
prop().map()...

What do you think, is it good way to do it?

@briancavalier
Copy link
Member

@iofjuupasli Yeah, there are various ways to simulate properties. Something like your example looks like it'll work in many cases. Properties often have other features, though, like truly atomic updates of the dependency graph, and properties are usually continuous (at least conceptually), while events are discrete. So just be aware that there are differences.

Also, have a look at @TylorS's most-subject, as well as @most/hold. They may be helpful for you. Cheers!

@TylorS
Copy link
Collaborator

TylorS commented Dec 9, 2015

@iofjuupasli You could take a look at flyd which has atomic updates, although from my understanding it's not continuous.

@mkaemmerer
Copy link

My understanding of Bacon and Kefir properties is that they are not continuous either. They are discrete, and retain their most recent value – analogous to @most/hold. If you don't need atomic updates, that's probably the easiest approach.

I do wish that the FRP landscape had a more agreed upon lexicon. It would make discussions like this one way easier.

@briancavalier
Copy link
Member

I do wish that the FRP landscape had a more agreed upon lexicon

Me too.

I'd go so far as to say that none of the currently popular reactive libraries is actually FRP. That's not an insult. For the record, most.js isn't FRP and doesn't intend to be. Rather, I just feel like these libs take an imperative approach, and/or don't deal with continuous time very well (or at all), which are two important characteristics of FRP.

For the FRP lexicon, I think it's important to look to Conal Elliott and Paul Hudak for authoritative terminology, which means Event and Behavior as the two main types. I don't know the history of the name "Property", but I'd be interested to find out. The name "Signal" (another continuous time-varying value) came from, as far as I know, signal processing.

Closing this as @most/hold (plus startWith if you need an initial value) is reasonable approximation, and most-subject is good for other imperative cases.

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

No branches or pull requests

4 participants