UseStrict

useStrict is a method to open strict mode in dob.

1
import { useStrict } from "dob"

Usage

1
useStrict()

Strict Mode

It’s not allow to change any observable value out of Action:

1
2
3
4
5
6
7
8
useStrict()

const obj = observable()
obj.title = "bob" // throw error!

Action(() => {
obj.title = "bob" // it's ok!
})

ESNext Usage

Action with decorator usage.

1
2
3
4
5
6
7
8
9
10
11
useStrict()

class SomeStore {}

class SomeAction {
@inject(SomeStore) store

@Action methodTwo() {
this.store.title = "bob" // it's ok!
}
}

cancelStrict

To cancle strict mode.

1
2
import { cancelStrict } from "dob"
cancelStrict()