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

22 tc39 observables #76

Merged
merged 14 commits into from
Jun 28, 2018
Merged

22 tc39 observables #76

merged 14 commits into from
Jun 28, 2018

Conversation

brianmhunt
Copy link
Member

@mbest - You can see I've added in support for the TC39 {next:...} style of argument to subscribe.

I use the argument-type (i.e. an object with a next method) to detect whether it's TC39-compliant call, in which case the current value of an observable is emitted immediately/synchronously.

It occurred to me that perhaps we want to have a different approach to this, such as adding a new event type (i.e. state instead of change). Any thoughts?

…tyle subscribe

So when a TC39 style `subscribe` call is made, we trigger with the current value immediately, contrasting with the prior behaviour - namely triggering only on changes to the state.

tc39/proposal-observable#190
…er arguments

This will be used by the JSX utility.
Now JSX binding arguments are known at the compile-time, so this ought to work:

```js
get template () {
   return <div ko-text={this.someValue}></div>
}
```
Sample:

```html
 <component x={alpha}></component>
```

… will be given `params={x: alpha}`
@brianmhunt brianmhunt merged commit 178e801 into master Jun 28, 2018
@brianmhunt brianmhunt deleted the 22-tc39-observables branch June 28, 2018 14:59
@mbest
Copy link
Member

mbest commented Jun 28, 2018

It occurred to me that perhaps we want to have a different approach to this, such as adding a new event type (i.e. state instead of change). Any thoughts?

I suggest that it be done with a new event type, which could also work with regular subscriptions. tc39 observables are just another way to consume a sequence of events. I don't think we should change the nature of that sequence based on the consumption technique.

@brianmhunt
Copy link
Member Author

Thanks @mbest, I think that's a good idea. Did you have any specifics in mind?

@mbest
Copy link
Member

mbest commented Jun 29, 2018

"state" would work. Implementation-wise, it should emit the current value and then become a regular "change" subscription.

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

Successfully merging this pull request may close these issues.

2 participants