You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! How can I create a ThunkAction to work with the rest api?
sample:
public IAction Get(Action.Get action) {
// return thunk to store, which will dispatch new actions upon success or failure
return new ThunkAction<State> ((dispatch, getState) => {
// dispatch first action to set state to loading
dispatch(new ApiRequestor.Action.GetStart {});
// use observable to subscribe and dispatch new actions from results
ObservableWWW
.Get(action.url)
.Subscribe(
successText => {
// dispatch second action on success
// Debug.Log($"ApiRequestCreator.Get success => dispatching successText: {successText}");
dispatch(new ApiRequestor.Action.GetSuccess{
text = successText
});
},
failureError => {
// dispatch second action on failure
// Debug.Log($"ApiRequestCreator.Get failure => dispatching failureError: {failureError}");
dispatch(new ApiRequestor.Action.GetFailure{
error = failureError
});
}
);
});
}
The text was updated successfully, but these errors were encountered:
Hi! How can I create a ThunkAction to work with the rest api?
sample:
The text was updated successfully, but these errors were encountered: