我们有这样的东西
public void OnStart()
{
StartCoroutine(setImage("http://drive.google.com/myimage.jpg"));
}
IEnumerator setImage(string url)
{
Texture2D texture = null;
WWW www = new WWW(url);
yield return www;
Debug.Log("Why on earh is this never called?");
texture = WWW.texture;
//end show Image in texture 2D
}
我们希望能够使用mobx-react class Store {
@observable foo: string;
@observable bar: string = "baz";
}
和Provider
覆盖init上的默认存储属性,如下所示:
@inject
new Store() //those will be same as defined in class
new Store({
foo: "foo's value to be as initial"
})
有很多方法可以在注入商店之前达到设置值的目的:
创建商店并只需修改其道具
在构造函数中使用类似的内容:
new Store({
foo: "foo's value to be as initial",
bar: "bar's value to be as initial"
})
但是哪种方法最好?