import { observer, action } from "mobx";
export interface Task {
id: string;
text: string;
done: boolean;
}
export class TodoStore {
@observable
public tasks: Task[] = [];
@action
public createTask = (task: Task) => {
this.tasks.push(task);
}
@action
public editTask = (i: number, task: Task) => {
this.tasks[i] = task;
}
@action
public deleteTask = (i: number) => {
this.tasks.splice(i, 1);
}
}
import kotlinx.android.synthetic.main.activity_main.fab
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
// ...
fab.setOnClickListener {
toast("Hello!")
}
}
}
class Greeter(val name: String) {
fun greet() {
println("Hello, $name")
}
}
String Interpolation to cut down ceremony.
fun main(args: Array<String>) {
Greeter(args[0]).greet()
}
+
Room
let textView = UITextView(frame: CGRect(
x: 20.0,
y: 90.0,
width: 250.0,
height: 100.0
))
self.automaticallyAdjustsScrollViewInsets = false
textView.center = self.view.center
textView.textAlignment = NSTextAlignment.justified
textView.textColor = UIColor.blue
textView.backgroundColor = UIColor.lightGray
import { observer, action } from "mobx";
export interface Task {
id: string;
text: string;
done: boolean;
}
export class TodoStore {
@observable
public tasks: Task[] = [];
@action
public createTask = (task: Task) => {
this.tasks.push(task);
}
@action
public editTask = (i: number, task: Task) => {
this.tasks[i] = task;
}
@action
public deleteTask = (i: number) => {
this.tasks.splice(i, 1);
}
}
X
sdkgen
github.com/cubos/sdkgen