MVC-TSX (WIP, alpha version)
MVC-TSX позволяет писать императивный код для построения реактивных приложений.
import React from "react";
import * as ReactDOM from "react-dom";
import {Model, View, Controller, on, arg} from "mvc";
class LoginModel extends Model {
login: string;
password: string;
}
class LoginController extends Controller<LoginModel> {
@on("change", ".Login--loginInput")
onChangeName( @arg("target", "value") inputValue ) {
this.model.set({
name: inputValue
});
}
@on("change", ".Login--passInput")
onChangeName( @arg("target", "value") inputValue ) {
this.model.set({
password: inputValue
});
}
@on("click", ".User--loginBtn")
onClickLogin() {
const {login, password} = this.model;
}
}
class LoginView extends View<LoginModel> {
controllers() {
return [
LoginController
];
}
template(loginModel: LoginModel>) {
return (<div className="Login">
<input className="Login--loginInput"/>
<input className="Login--passInput"/>
</div>);
}
}
const loginModel = new LoginModel();
ReactDOM.render(
<LoginView model={loginModel}/>,
document.getElementById("root")
);