July 2018
Beginner
236 pages
5h 34m
English
Decorators are a syntactic feature that allow you to attach behavior to a class and its fields. We have already seen this in Chapter 3, A React App with MobX, so the following code should be very familiar:
class BookSearchStore { @observable term = 'javascript'; @observable status = ''; @observable.shallow results = []; @observable totalCount = 0;}
Using the @observable decorator, you can make properties of a class into observables. This is the recommended approach to start modeling your observables. By default, @observable applies deep observability, but there are some specialized decorators that give you more control.
Read now
Unlock full access