Methods - Raiondesu/Tuex GitHub Wiki

Methods are the most advanced and flexible part of Tuex, as they can be used for almost anything: changing values, calling setters or making async calls to backend API.

A Native JavaScript Concept

The concept of methods as properties of an object is also native for the JavaScript language. If you are familiar with JS - then you are familiar with methods already. But there are still some aspects to be considered when using Tuex.

Tuex-Enhanced Methods

Let's create a simple Tuex store with a method:

const tuex = new Tuex.Store({
  num: 0,
  increase(amount) {
    this.num += amount;
  }
});

Similar to setters, Tuex knows, when methods are called and what arguments they recieve:

tuex.store.increase(10, 2);

Methods can return promises, values or nothing.