This repository has been archived by the owner on Jan 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Methods
Alexey edited this page Jan 15, 2018
·
1 revision
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.
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.
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.
Some text may be borrowed from official Vuex documentation