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

Add a value property getter & setter to the key module/observable #32

Merged
merged 2 commits into from
Jul 4, 2018

Conversation

chasenlehara
Copy link
Member

This adds an API for getting & setting the value of the observation returned by the key module:

import keyObservable from "can-simple-observable/key/key";

const outer = {inner: {key: "hello"}};
const observable = keyObservable(outer, "inner.key");

observable.value; // is "hello"

observable.value = "goodbye";
observable.value; // is now "goodbye"

This PR doesn’t include docs because there are no docs for the key module (it’s used by can-value and will be mentioned there).

Related to canjs/can-observation#130

This adds an API for getting & setting the value of the observation returned by the key module:

```js
import keyObservable from "can-simple-observable/key/key";

const outer = {inner: {key: "hello"}};
const observable = keyObservable(outer, "inner.key");

observable.value; // is "hello"

observable.value = "goodbye";
observable.value; // is now "goodbye"
```

Related to canjs/can-observation#130
@chasenlehara
Copy link
Member Author

The tests are failing right now because can-observation uses .value internally, which causes infinite recursion, but that should be fixed after canjs/can-observation#135 is merged (and I’ll update the dependency here so older versions aren’t used).

This is so that the `key` module can provide its own `value` getter & setter.
@chasenlehara chasenlehara merged commit cf91ec2 into master Jul 4, 2018
@chasenlehara chasenlehara deleted the key-value branch July 4, 2018 03:03
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.

None yet

2 participants