Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Artur Dębkowski
    @ekhart
    try to add using UniRx; to the script
    kgc00
    @kgc00

    Hi guys,

    new to unirx, sorry if this has been asked- Is there some preferred way to fire off an event or method at under specific conditions? For example

    // hp = reactiveproperty<float>
    if (hp <= 0) execute()

    I'm currently messing around with ReactiveProperties and the MessageBroker to try and achieve this but am not sure if this is the correct aproach

                hp.Select(x => x <= 0).Subscribe(x => {
                    if (x) {
                        Debug.Log("Fire!");
                        MessageBroker.Default.Publish(new Empty());
                        hp.Dispose();
                    }
                }).AddTo(this);

    Does this seem like an okay way to achieve this functionality?

    kgc00
    @kgc00

    ended up here:

    gameObject.UpdateAsObservable().SampleFrame(30).Where(_ => hp <= 0).Distinct().Subscribe(_ => {
                    Debug.Log("Fire!");
                    MessageBroker.Default.Publish(new Empty());
                }).AddTo(this);

    any way to make it so everytime it goes from > 0 to <= 0 it fires?

    kgc00
    @kgc00
    so like:
    100 => 0
    fires once
    0 => 20
    20 => 0
    fires once
    etc
    Jonathan Bro
    @Nomy1
    If you give it a buffer for the previous value then you can compare it with the next value and determine if it's going from positive to negative
    kgc00
    @kgc00
    Thanks! I'll try it out
    kgc00
    @kgc00
    Turns out the pairwise operator was a bit simpler for that usecase so i went with that instead =)
    Jonathan Bro
    @Nomy1
    What's pairwise? A tuple?
    kgc00
    @kgc00
    exactly, it combines the last 2 events in the stream so you can do something like:
    x.OnValueChangedAsObservable()
                    .Where(_ => hp <= 0)
                    .Pairwise()
                    .Where(x => x.Current && !x.Previous)
                    .Subscribe(_ => HandleEvent());
    vbandi
    @vbandi
    Unfortunately, it seems like UniRX has been abandoned. Does anyone know if there's a public/community fork that's being kept up-to-date?
    sparkdsd
    @sparkdsd

    Hi guys!

    var a = new ReactiveProperty<bool>();
    _button.OnClickAsObservable().Subscribe(_ => a.Value = !a.Value); 
    
    a.SelectMany(v => v ? Observable.EveryUpdate().Select(_ => true) : Observable.Return(false)).Subscribe(v => Debug.Log(v));

    I only want Debug.Log work if a.Value==true and when a.Value==false nothing should happen
    But with this code if I switch a.Value = false - Console once print false and then continuously true ( obviously from EveryUpdate )

    Gwendal Broudin
    @GwendalBroudin
    Hi @neuecc thanks for these amazing library, I would love to use these in a long term industrial project. Unfortunately, as @vbandi said, there not a lot of activity those days, is the project still maintained?
    Kevin Streicher
    @NoxMortem
    @vbandi, @GwendalBroudin as @neuecc just merged in code on the 17.4 I wonder what makes you thinkt he project is dead? He is just not extremly active here on gitter as he also maintains a lot of other projects. What feature are you missing? Btw you can check https://github.com/neuecc/UniRx/pulse to see how active it is.
    However, obviously there are tons of issues that should be resolved :)
    vbandi
    @vbandi
    @NoxMortem We are in 20201 - that 17.4 merge hasn't just happened, it was a year ago, in 2020 :) And the last Release is dated almost 2 years ago, in July 2019. There are 38 open PRs, some as recent as last month some like yours from last year, without any merging or comment from the project owner.
    Kevin Streicher
    @NoxMortem
    @vbandi time flies... what a year
    Jonathan Bro
    @Nomy1
    I do hope UniTask is kept up to date at least. I use it a LOT
    Valeri Strucovski
    @vstrucovski_twitter
    image.png
    hello guys, I have question about unitask
    is it possible to write this code shorter, part about Unitask.Action
    Jonathan Bro
    @Nomy1
    Do you need Unitask action? Why not just remove it and type async directly before the _
    Valeri Strucovski
    @vstrucovski_twitter
    @Nomy1 not actually, it's my try to fight with realtime error "OperationCanceledException: The operation was canceled.", which appears with plain 'async _' code
    Szymon Gatner
    @slimshader
    hey everyone! is it also ok to ask questions about MagicOnion here?
    Michael Greenwald
    @mikey555
    From my experiments, I'm finding that Aggregate only fires OnNext when it observes an OnComplete. Is this always the case, or can I somehow make Aggregate fire OnNext when it receives an OnNext?
    Michael Greenwald
    @mikey555
    Never mind, I see this is how Aggregate works. I didn't realize it was also called Reduce in other Rx versions.
    Artur Dębkowski
    @ekhart
    Aggregate is part of older LINQ in fact
    Andy
    @uhbgvfre
    can I use UniRx to traverse bool[3] to find first true, if no result {return custom default value}
    Artur Dębkowski
    @ekhart
    actually, you don't need UniRx - just LINQ
    bools.FirstOrDefault(_ => _ is true)
    Andy
    @uhbgvfre
    Thanks @ekhart
    How can I fix my code err, m_CsBtnStates is bool[6], I want observable result(IObservable<bool>) transfer to bool array
    m_CsBtnStates = signals.ToObservable().Select(x => !x.State);
    1 reply
    Andy
    @uhbgvfre
    and can i use any simple way to refactor this scope
    for (int i = 0; i < m_Signals.Length; i++)
    {
          m_Signals[i].HubPort = i;
          m_Signals[i].IsHubPortDevice = true;
          m_Signals[i].Open(1000);
    }
    EbiPenMan
    @EbiPenMan
    Hi, Is there a complete project that uses UniRX? Which can be examined as an example?
    Artur Dębkowski
    @ekhart
    This message was deleted
    Andy
    @uhbgvfre
    How to instead IObservable<bool> to bool
    anyBtnInteractStream.Throttle(TimeSpan.FromSeconds(3f)).Repeat()
            .Where(_=>playerStateStream.LastOrDefault(x=>x).OfType<bool>())
            .Subscribe(_ => onPlayerInButNoOperateForAWhile.Invoke());
    mruce
    @mruce
    Noob here - hi!
    Looking for help with fairly trivial (I hope) question:
    I have float property, that when changed, executes some code that requires a texture; texture itself is initialized afer a while - so float change might occur when texture is null.
    How can I RX it to make sure float change would trigger the code only it texture is already set? Also - if texture is initialized after float change, it should execute the code as well.
    Jean-Marc Primeau
    @jmprimeau

    @mruce maybe consider something like this:

    var p = new ReactiveProperty<float>();
    var t = this.ObserveEveryValueChanged(_ => GetComponent<Texture>()).Where(_ => _ != null);
    p.CombineLatest(t, (pp,tt) => { /*do stuff here and be certain that the texture (or whatever property is not null) */ }).Subscribe().AddTo(this);

    Not sure where the texture is, but essentially, you make it into a reactive value also and make sure it isn't null, then you do stuff to it only in a combine latest with the float.

    Thomas
    @thsbrown
    Hey guys just wanted to first ask if this is the de facto place for UniRx help / community?
    It looks like there was some discussion over on github about slack / discord being used so I wasn't sure if the community had moved there
    Wilfredo Velázquez-Rodríguez
    @Zulu-Inuoe
    @thsbrown Did you ever get an answer? I was looking to pick some people's brains on some UniRx patterns
    Artur Dębkowski
    @ekhart
    This is somehow official place for UniRx. But I also see not so much activity here.
    But there is more active Infallible Code Discord with UniRx channel: https://discord.gg/U2E2HrJZ
    Wilfredo Velázquez-Rodríguez
    @Zulu-Inuoe
    Neat. Thank you. I'll keep poking my head around here but I'll also check out that Discord server
    Enescan BEKTAŞ
    @wewrere41
    neuecc/UniRx#520
    TimeScale doesn't affect. Timer work although TimeScale=0.
    Time.timeScale = 0;
    Observable.Timer(TimeSpan.FromSeconds(5), Scheduler.MainThread).Subscribe(_ =>
                        { 
                            Debug.Log(Time.time); // Its logging while TimeScale=0
                        });
    Fontaine Thomas
    @Kaiymu

    Hello !

    I hope everyone is doing well :D.
    Do you know if a tool exist, knowing at a moment which Observable are currently running ?
    I would like to use it as a debug tool if possible and check that I'm not leaking any Subscribe and forget to use the Dispose on them.

    I know a similar tool exist for UniTask, so who knows !

    Thanks !

    Ash McConnell
    @AshMcConnell_twitter
    Does anyone know how to reduce a stream to a stream of arrays? in rxjs I would do something like this : -myStream.pipe(reduce((myArray, item) => myArray.push(item), []); Is there an equivalent in UniRX?
    Ash McConnell
    @AshMcConnell_twitter
    I think I have it: -
    List<long> accumulator = new();
                AllSectorsObs = SectorTimeObs.Scan(accumulator,(sectors, sectorTime) => {
                    sectors.Add(sectorTime);
                    return sectors;
                });
    Is that a sensible way to do it?
    Thanawat Techaumnuaiwit
    @thiskappaisgrey

    Hi, I'm trying to implement a parry mechanic with UniRx, so I have 2 observables:

    // emits when player is damaged
    IObservable<AttackContext> obsDmgEvent = ...
    // emits when player presses the shield button
    IObservable<bool> shieldPressed = ....

    I want to combine these 2 in such a way that I don't damage the player if the shield button was pressed within an interval. For example, given my interval is .5s, if I press shield at 0s and got dmg at .2s, I shouldn't get damaged because I parried. I'm not sure what RxMethod to use. I was looking at Buffer or Join but they don't seem to fit my needs.. thank you..

    I guess this is kind of the opposite of longpress..

    Ash McConnell
    @AshMcConnell_twitter
    Does anyone have any ideas about testing non-completing observables. In rxjs I can use fakeAsync and tick(), is there an equivalent here? Wait() won't work as I believe it is only for observables that complete.
    Ash McConnell
    @AshMcConnell_twitter
    @thiskappaisgrey I know rxjs better than unirx, but could you use something like this: -
    damageStream = obsDmnEvent.debounceTime(200).withLatestFrom(shieldPressed).map([attack, shieldUp] => if (shieldUp) return 0 else return someDamage)
    I think Throttle or ThrottleFirst is the equivalent of debounceTime neuecc/UniRx#356