Development Environment

To help with development, and prevent some sneaky bugs that can be hard to debug, ActiveJS provides a few checks that you can enable in a development environment. You can configure them like this.

Configuration.set({
checkUniqueId: true, // default is false
checkImmutability: true, // default is false
checkSerializability: true // default is false
})

ActiveJS provides the following checks:

  • checkImmutability Enables immutability violation checks for all the ActiveJS constructs, it blocks any attempts of state mutation and throws an error with information about where the violation occurred.

  • checkUniqueId Enables unique id checks across all the ActiveJS constructs, such that if any of the two ActiveJS instances have the same id, it'll throw an error.

  • checkSerializability Enables serializability checks for Units and Actions, it'll throw an error if a non-serializable value is passed to an Action or Unit.

See API reference for more details.

Notes

  • You should only use these checks in a development environment to avoid causing unwarranted errors in a production deployment.

  • To automate this process you can use an environment variable provided by the framework of your choice, that identifies the development environment, and enable ActiveJS' production mode to disable all the checks. e.g.: in Angular it'd look like this

    // in the app.module.ts
    if (environment.production) {
    Configuration.enableProdMode();
    }