Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does @observable have to be used on every field?

I've noticed if I do not use @observable in any of my web ui code all fields/members changes are picked up automatically with the data binding syntax.

The issue I run into is when picking one field in a class that extends WebComponent and applying the @observable annotation, now other fields dont bind correctly and display changes.

Is this a known issue or correctly functionality?

If I use @observable annotation once, should I be applying it to all fields?

like image 729
adam-singer Avatar asked Feb 16 '23 15:02

adam-singer


1 Answers

As mentioned in another post, you have the option of marking a class with @observable.

You're currently caught between observables and watchers. Watchers (and dispatch) are the old way, soon to be phased out. Observables are the new way. In order not to break old clients, we kept watchers in. If you used at least one @observable, then the watcher system is disabled.

The new MDV v2 implementation is getting ready. I suggest you use @observable for anything you want observed. Stop using dispatch() everywhere. Also, stop using observable top-level fields, because they won't be bindable into a node.

Apologies, things are really in a state of flux. I suspect things will settle quite soon.

I suggest reading more about MDV v2 here: https://github.com/toolkitchen/mdv/blob/stable/README.md to get ready for the change.

I suspect @observable will continue to be an option, so it's OK to keep using that now.

like image 54
Seth Ladd Avatar answered Feb 19 '23 19:02

Seth Ladd