Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ObserveEveryValueChanged未接收所有更改_C#_Unity3d_Reactive_Unirx - Fatal编程技术网

C# ObserveEveryValueChanged未接收所有更改

C# ObserveEveryValueChanged未接收所有更改,c#,unity3d,reactive,unirx,C#,Unity3d,Reactive,Unirx,我正在使用UniRx库扩展,它是unity的一个被动扩展,基于System.reactive构建。我有一个订户,负责打印它收到的值(不仅如此,在这种情况下,它的整个代码都是无用的) 这就是流程,我确切地知道它更改了“State”变量,我曾尝试通知自己更改,但我想从它更改为反应式编程,以使语法更加清晰 单击一个按钮调用一个函数,该函数将状态更改为工作状态(ObserveEveryValueChanged未接收到的状态),然后我调用一个异步方法,该方法将在等待方法完成时将“状态”更改为成功 publ

我正在使用UniRx库扩展,它是unity的一个被动扩展,基于System.reactive构建。我有一个订户,负责打印它收到的值(不仅如此,在这种情况下,它的整个代码都是无用的)

这就是流程,我确切地知道它更改了“State”变量,我曾尝试通知自己更改,但我想从它更改为反应式编程,以使语法更加清晰

单击一个按钮调用一个函数,该函数将状态更改为工作状态(ObserveEveryValueChanged未接收到的状态),然后我调用一个异步方法,该方法将在等待方法完成时将“状态”更改为成功

public void FetchMoreItems(string accountName, string cursor)
{
    _store.Dispatch(new FetchMoreItems());
    _services.fetchInventoryService.FethInventoryMore(
        accountName,
        cursor,
        (_cursor, _items) => _store.Dispatch(new FetchMoreItemsSucces(_cursor, _items)),
        () => _store.Dispatch(new FetchItemFail()),
        (_cursor, _items) => _store.Dispatch(new InventoryFinished(_cursor, _items)));
}



public async void FethInventoryMore(string accountName, string cursor, Action<string, List<Item>> success, System.Action fail, Action<string, List<Item>> finishedInventory)
{
    await MockFetchInventory(accountName, cursor, success, fail, finishedInventory);
}

private Task MockFetchInventory(string accountName, string cursor, Action<string, List<Item>> success, System.Action fail, Action<string, List<Item>> finishedInventory)
{
    return Task.Factory.StartNew(() =>
    {
        if (accountName == "John" && (cursor == "newCursor" || cursor == "secondNewCusor"))
        {
            List<Item> items = new List<Item>
                {
                    new Item(null, ItemType.Movement, 1, 1, 1, 3),
                    new Item(null, ItemType.Digger, 1, 3, 1, 1),
                    new Item(null, ItemType.Chest,230, 0, 0, 0),
                    new Item(null, ItemType.Key, 0, 0, 0, 0),
                    new Item(null, ItemType.Locator, 1, 1, 2 ,4)
                };

            if (cursor == "newCursor")
            {
                success("secondNewCusor", items);
            }
            else
            {
                items = new List<Item>
                {
                    new Item(null, ItemType.Movement, 1, 1, 1, 3),
                    new Item(null, ItemType.Digger, 1, 3, 1, 1)
                };
                finishedInventory("", items);
            }
        }
        else
        {
            fail();
        }
    });
}
public void FetchMoreItems(字符串accountName,字符串游标)
{
_store.Dispatch(新的FetchMoreItems());
_services.fetchInventoryService.FethInventoryMore(
帐户名,
光标,
(_cursor,_items)=>_store.Dispatch(新的FetchMoreItemsAccess(_cursor,_items)),
()=>_store.Dispatch(新的FetchItemFail()),
(_cursor,_items)=>_store.Dispatch(新库存完成(_cursor,_items));
}
public async void FethInventoryMore(字符串accountName、字符串游标、操作成功、系统操作失败、操作完成ventory)
{
等待MockFetchInventory(accountName、游标、成功、失败、finishedInventory);
}
私有任务MockFetchInventory(字符串accountName、字符串光标、操作成功、系统操作失败、操作完成库存)
{
返回Task.Factory.StartNew(()=>
{
if(accountName==“John”&&(cursor==“newCursor”| | cursor==“secondNewCusor”))
{
列表项=新列表
{
新项(null,ItemType.Movement,1,1,1,3),
新项(null,ItemType.Digger,1,3,1,1),
新项目(空,ItemType.Chest,230,0,0,0),
新项(null,ItemType.Key,0,0,0),
新项(null,ItemType.Locator,1,1,2,4)
};
如果(光标==“新光标”)
{
成功(“第二个新客户”,项目);
}
其他的
{
项目=新列表
{
新项(null,ItemType.Movement,1,1,1,3),
新项(null,ItemType.Digger,1,3,1,1)
};
已完成的库存(“,项);
}
}
其他的
{
失败();
}
});
}
public void FetchMoreItems(string accountName, string cursor)
{
    _store.Dispatch(new FetchMoreItems());
    _services.fetchInventoryService.FethInventoryMore(
        accountName,
        cursor,
        (_cursor, _items) => _store.Dispatch(new FetchMoreItemsSucces(_cursor, _items)),
        () => _store.Dispatch(new FetchItemFail()),
        (_cursor, _items) => _store.Dispatch(new InventoryFinished(_cursor, _items)));
}



public async void FethInventoryMore(string accountName, string cursor, Action<string, List<Item>> success, System.Action fail, Action<string, List<Item>> finishedInventory)
{
    await MockFetchInventory(accountName, cursor, success, fail, finishedInventory);
}

private Task MockFetchInventory(string accountName, string cursor, Action<string, List<Item>> success, System.Action fail, Action<string, List<Item>> finishedInventory)
{
    return Task.Factory.StartNew(() =>
    {
        if (accountName == "John" && (cursor == "newCursor" || cursor == "secondNewCusor"))
        {
            List<Item> items = new List<Item>
                {
                    new Item(null, ItemType.Movement, 1, 1, 1, 3),
                    new Item(null, ItemType.Digger, 1, 3, 1, 1),
                    new Item(null, ItemType.Chest,230, 0, 0, 0),
                    new Item(null, ItemType.Key, 0, 0, 0, 0),
                    new Item(null, ItemType.Locator, 1, 1, 2 ,4)
                };

            if (cursor == "newCursor")
            {
                success("secondNewCusor", items);
            }
            else
            {
                items = new List<Item>
                {
                    new Item(null, ItemType.Movement, 1, 1, 1, 3),
                    new Item(null, ItemType.Digger, 1, 3, 1, 1)
                };
                finishedInventory("", items);
            }
        }
        else
        {
            fail();
        }
    });
}