Sign in
Log inSign up
Sai Kishore Komanduri

21 likes

·

263 reads

6 comments

Marek Prihoda
Marek Prihoda
Nov 14, 2016

There is a mistake in the new commit that was supposed to fix the problem when clicking the checkboxes.

@observable this.isDone;

should be

@observable isDone;

2
·
·1 reply
Sai Kishore Komanduri
Sai Kishore Komanduri
Author
·Nov 15, 2016

Thanks for the heads-up @marekp! I'd fixed this locally but forgot to push the change to remote. Here is the fixed commit.

1
·
Alex Valex
Alex Valex
Nov 6, 2016

Looks like current mobx branch code does not respond to checkbox action. What is the process to figure out what went wrong with MobX magic?

1
·
·1 reply
Sai Kishore Komanduri
Sai Kishore Komanduri
Author
·Nov 7, 2016

Hi, @alexvalex! Thanks for pointing out the error. It was due to this commit.

From MobX's @observable documentation:

If value is an object with a prototype, a JavaScript primitive or function, a Boxed Observable will be returned. MobX will not make objects with a prototype automatically observable; as that is the responsibility of its constructor function. Use extendObservable in the constructor, or @observable in its class definition instead.

By removing the observable on the isDone property of the Todo objects in the above commit, MobX was not reacting to the changes in Todo objects.

This is now fixed, in the mobx branch; and everything should work as expected. Let me know, if you run into any more problems. :)

1
·
Marek Prihoda
Marek Prihoda
Nov 14, 2016

Great tutorial, thanks! However, it is not very clear to me how come that the list of visible todos gets updated when user adds a new todo. Seems like a real magic to me. How does the TodoApp learn about the updated todos?

1
·
·1 reply
Sai Kishore Komanduri
Sai Kishore Komanduri
Author
·Nov 15, 2016

We have specified, the todos array as an @observable. Whenever we make any changes to an @observable; the components decorated with @observer will autorun/rerun the render method.

Similarly, with @computed, whenever an @observable changes; the functions decorated with @computed are run, which get the required properties from the@observable data, and they compute the derivations, as required... and that's how we get visibleTodos.

If you're interested to know more, check out the MobX docs. They're very well written.

1
·