Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If two promise calls are consecutive, theirs then & always block never get called #27

Open
anhduyleatiheart opened this issue Mar 22, 2021 · 0 comments

Comments

@anhduyleatiheart
Copy link

anhduyleatiheart commented Mar 22, 2021

viewModel.load() method:

func load() -> Promise<ContentDirectory>? {
        ...
                return .success(playlistDirectory)
            }, queue: DispatchQueue.main)
        }, queue: .main)
        .then({ obj in
            return .success(obj)
        }, always: { [weak self] in
            self?.promise = nil
        }, queue: DispatchQueue.main)
        return promise
}

View Controller method:

private func loadModel() {
        loadCancelToken?.cancel()
        guard let promise = viewModel.load() else { return }

        showWaitCursorAtCenter()

        loadCancelToken = promise.then({ [weak self] _ in
            ...
        }, always: { [weak self] in
            ...
        }, queue: DispatchQueue.main)
}

When loadModel method is called twice in a row and the promises are fulfilled, both loadModel's then & always blocks from both calls never hit the breakpoint and never get called.

View Model load()'s then & always blocks from both calls did get called though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant