This section uses parts of the code created in previous tutorial parts.
Before we'll start watching the store, let's add some utility functions to it so it'll be easier to work with.
We can already modify the store calling code like this directly:
It is however quite verbose and it might be good idea to add store related functions to the store itself. For example:
Now we could add new todo with
We can add a few more utility functions to our store:
Right now, our store is a bit more 'smart'. We can call
todos.removeTodo(1) directly on it instead of modifying its data directly.
Having such utility functions is also useful for validation of performed operations, etc.
Don't use this keyword
Note that inside utility functions, we don't use