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

Reactive property doesn't react to the changes during initial subscription #251

Open
orcharddweller opened this issue Aug 23, 2024 · 1 comment

Comments

@orcharddweller
Copy link

Amazing library!
I've found one weird thing. I'm not sure if this is a bug, but ReactiveProperty will ignore changes to its value if the changes happen based on the value pre-subscription.

example bellow

using R3;
using UnityEngine;

public class AsyncTest : MonoBehaviour
{
    private readonly ReactiveProperty<int> a = new();

    private void Start()
    {
        var d = Disposable.CreateBuilder();

        a.Do(v => Debug.Log($"a {v}")).Do(v =>
        {
            if (v < 20)
            {
                a.Value += 1;
            }
        }).Subscribe().AddTo(ref d);

        Debug.Log($"a == 1: {a.CurrentValue == 1}"); // this should be 20, not 1!

        a.Value = 0; // this 

        Debug.Log($"a == 20: {a.CurrentValue == 20}"); // this is correct

        d.RegisterTo(destroyCancellationToken);
    }
}
@neuecc
Copy link
Member

neuecc commented Aug 26, 2024

Thank you.
While the first value is being issued, it is still treated as though the Subscribe has not been completed.
This is the specification.

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

2 participants