Riot.js – nice React alternative
Recently I’m looking for easier versions of popular libraries. There is a lot of buzz around Facebook React.js library, but i found it not especially user / developer friendly – at least at first glitch. Obviously some people says that it’s not so complicated, but… there is something super simple and super light – Riot.js .
Advertised as A REACT- LIKE, 3.5 KB USER INTERFACE LIBRARY – i’ve been using it so far only for routing (it’s small, it’s nice and fast) but looks like a good candidate for more serious actions. Obviously it’s very modular, it has observable, custom tags, mentioned earlier router. Looks pretty straight forward, especially with examples like that:
// Login API
var auth \= riot.observable()
auth.login \= function(params) {
$.get('/api', params, function(json) {
auth.trigger('login', json)
})
}
<login\>
<form onsubmit\="{ login }"\>
<input name\="username" type\="text" placeholder\="username"\>
<input name\="password" type\="password" placeholder\="password"\>
form\>
login() {
opts.login({
username: this.username.value,
password: this.password.value
})
}
// any tag on the system can listen to login event
opts.on('login', function() {
$(body).addClass('logged')
})
login\>