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

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

@LoopIssuer

Description

@LoopIssuer

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions