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

Can you add a public static Observable<T> TakeWhile<T, TOther>(this Observable<T> source, Observable<TOther> other) method? #306

Closed
binarylzc opened this issue Feb 11, 2025 · 1 comment

Comments

@binarylzc
Copy link

        isOdd=playerInput.PlayerBattleInput.Aim.PerformedAsObservable()
        .Scan(0,(count,_)=>count+1)
        .Select(count=>count%2==1)
        .Share();

        isOdd
        .Select(isOdd=>{
            isAiming=isOdd;
            return Observable.EveryUpdate().WithLatestFrom(aTBB.currentPlayer,(_,player)=>player);
        })
        .Switch()
        .TakeWhile(_=>isAiming)
       .Subscribe()

I really need another way to cancel an Observable. Takeuntil can only handle one case, otherwise I have to create another Observable that needs negation, or cache a member variable.

@neuecc
Copy link
Member

neuecc commented Feb 13, 2025

maybe you can use TakeUntil<T>(this Observable<T> source, Func<T, CancellationToken, ValueTask> asyncFunc) operator.

@neuecc neuecc closed this as completed Feb 14, 2025
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