Reactive, functional and declarative framework for webapps
Setter allows you to define an interface to save data from outside to the Wu data model.
Third-party libraries ➤ Setter (pure function) ➤ Reactive data model.
| Properties | Required |
|:—————————————————-:|:——–:|
| args
| Optional |
| run
| Optional |
| update
| Required |
// file user.js
wu.create('setter', 'userSendLoginData', { // name of the setter item
// pure function
run: (email, password) => {
return {
email,
password
}
},
// path of the data model where to save the result of 'run'
update: 'user.login.data'
})
// file userLogin.template.js
sendLoginData () {
wu.setter('userSendLoginData', 'email@email.com', '12345678')
}
// when 'sendLoginData' is executed 'user.login.data' will have { email: 'email@email.com', password: '12345678' }
// file user.js
wu.create('setter', 'userSendLoginData', { // name of the setter item
// arguments that will receive the function 'run'
args: 'user.profile.email',
// pure function
run: (email, password) => {
return {
email,
password
}
},
// path of the data model where to save the result of 'run'
update: 'user.login.data'
})
// file userLogin.template.js
sendLoginData () {
wu.setter('userSendLoginData', '12345678')
}
// when 'sendLoginData' is executed 'user.login.data' will have { email: 'email@email.com', password: '12345678' }
run
function// file user.js
wu.create('setter', 'userSendLoginData', { // name of the setter item
// if 'run' function is not specified, the default function is (arg) => arg
// it means, the function returns the first argument that receives
update: 'user.login.data'
})
// file userLogin.template.js
sendLoginData () {
wu.setter('userSendLoginData', {
email: 'email@email.com',
password: '12345678'
})
}
// when 'sendLoginData' is executed 'user.login.data' will have { email: 'email@email.com', password: '12345678' }