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 observable class field support #32

Merged
merged 7 commits into from
Jun 11, 2020
Merged

Conversation

cherifGsoul
Copy link
Member

For example:

class Person extends ObservableObject{
		greetings = 'Hello';
		static get props() {
			return {
				greetings: 'Bonjour'
			};
		}
}

const cherif = new Person();

cherif.on('greetings', function (ev, newVal, oldVal) {
	    // it should be observable, handle change here
});

// Property change trigger the handler
cherif.greetings = 'Hola';

For canjs/can-observable-mixin#79

@@ -96,6 +96,27 @@ myInstance.prop = "NEW VALUE";
```
@codepen

#### Observable class fields

`ObservableObject` [class fields](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Class_fields) are observables like [can-observable-object/object.static.props static props]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be good:

ObservableObject class fields are also observable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@phillipskevin The docs are updated, can you review one more time?

Copy link
Contributor

@phillipskevin phillipskevin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good @cherifGsoul!

@cherifGsoul cherifGsoul merged commit 41c2446 into master Jun 11, 2020
@cherifGsoul cherifGsoul deleted the observable-class-properties branch June 11, 2020 17:54
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