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

Update order of invocation in -sendNext: RACReplaySubject #154

Conversation

zulkis
Copy link
Contributor

@zulkis zulkis commented Mar 14, 2019

valuesReceived should be cleaned up before sending value.

If we have subscription and creating another subscription on the same RACReplaySubject while -take:1 it - we can get first value instead of second.

RACReplaySubject *subject = [RACReplaySubject replaySubjectWithCapacity:1];
        [subject subscribeNext:^(id  _Nullable item1) {
            NSLog(@"%@", item1);
            [[subject take:1] subscribeNext:^(id  _Nullable item2) {
                NSLog(@"%@", item2);
            }];
        }];
        [subject sendNext:@"first"];
        [subject sendNext:@"second"];

Expected:

first
first
second
second

Got:

first
first
second
first

valuesReceived should be cleaned up before sending value.

If we have subscription and creating another subscription on the same RACReplaySubject while -take:1 it - we can get first value instead of second.
@zulkis zulkis changed the title Update order of invocation in sendNext: RACReplaySubject Update order of invocation in -sendNext: RACReplaySubject Mar 14, 2019
@mdiep
Copy link
Contributor

mdiep commented Mar 15, 2019

That seems reasonable. Can you add a test?

@zulkis
Copy link
Contributor Author

zulkis commented Mar 28, 2019

Will do. Still, I am not sure why one MR check is failing because of some validation error. Any advice on it?

@mdiep
Copy link
Contributor

mdiep commented Mar 28, 2019

Things look good here. Thanks!

@mdiep mdiep merged commit b62aa6f into ReactiveCocoa:master Mar 28, 2019
stuartofmine pushed a commit to stuartofmine/ReactiveObjC_2023 that referenced this pull request Oct 18, 2023
…ext-bug-with-values-array-clean-up

Update order of invocation in -sendNext: RACReplaySubject
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

Successfully merging this pull request may close these issues.

2 participants