Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Make repeat on error, but when other Observable method succeed #522

Open
LoopIssuer opened this issue Oct 5, 2022 · 0 comments
Open

Make repeat on error, but when other Observable method succeed #522

LoopIssuer opened this issue Oct 5, 2022 · 0 comments

Comments

@LoopIssuer
Copy link

LoopIssuer commented Oct 5, 2022

Hi,
I am struggling with this:
I need to make the method (MainAction) repeat on error, but after another method (ActionOnError) would do something with success.

This is quasi code, not working:

        public void MainAction()
        {
            _cognitoAuthorizationController.GetUserSubId("accessToken")
                .Subscribe(r =>
                {
                    Debug.Log("Succes");
                },
                onError:
                err =>
                {
                    Debug.Log("err " + err.Message); 
                    ActionOnError().Subscribe(
                    success =>
                    {
                        if (success)
                        {
                            MainAction();
                        }
                    });
                });
        }

        public IObservable<string> GetUserSubId(string accessToken)
        {
            return GetUserId(accessToken).ToObservable();
         }
        
        public async Task<string> GetUserId(string accessToken)
        {
            Debug.Log("Getting user's id...");
            string subId = "";
            Task<GetUserResponse> responseTask =
                _provider.GetUserAsync(new GetUserRequest
                {
                    AccessToken = accessToken
                });
            GetUserResponse responseObject = await responseTask;
            return responseObject.subId;
        }

Thank you in advance for any help.

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant