Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7826793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T09:35:01+00:00 2026-06-02T09:35:01+00:00

I have three (or more) observable sequences of bool : IObservable<bool> a0 = …;

  • 0

I have three (or more) observable sequences of bool:

IObservable<bool> a0 = ...;
IObservable<bool> a1 = ...;
IObservable<bool> a2 = ...;

These sequences generate mostly false values but once in a while there is a true (the sequences can also be empty). I’m not interested in the values themselves but rather in the order of the true values. So if a0 is true, then a2 is true and finally a1, I’d like to perform some action:

(a0, a2, a1) => ...do something...

But if the true values appear in another order, I’d like to do something else:

(a2, a1, a0) => ...do something else...
(a0, a1, a2) => ...do something entirely else...

So I’m only interested in the first true value of each sequence and depending on the order in which they occur, I’d like to perform some action.

I could record the timestamp of each first occurrence of true and then sort in a CombineLatest call, but I have a feeling there is a better way. One problem with this approach is that I am now dependent on granularity of recorded timestamps.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T09:35:03+00:00Added an answer on June 2, 2026 at 9:35 am

    Firstly, you only need the true values so ignore the rest. Second, you can encode each observable into a more semantic meaning (perhaps a string?). Third, you can then merge these streams, wait for 3 values to arrive, and act based on them.

    Set up:

    var a0 = new Subject<bool>();
    var a1 = new Subject<bool>();
    var a2 = new Subject<bool>();
    

    Encoding:

    var a0t = a0.Where(x => x).Select(x => "a0").Take(1); // thanks Matthew Finlay
    var a1t = a1.Where(x => x).Select(x => "a1").Take(1);
    var a2t = a2.Where(x => x).Select(x => "a2").Take(1);
    

    Merge and get after three values:

    var merged = a0t.Merge(a1t).Merge(a2t);
    var message = merged.Buffer(3).Subscribe(x => ProcessMessage(String.Join("", x)));
    

    The processing section:

    public void ProcessMessage(string message)
    {
        switch(message) {
            case "a0a1a2": Console.WriteLine("1"); break;
            case "a1a2a0": Console.WriteLine("2"); break;
            case "a2a1a0": Console.WriteLine("3"); break;
        }
    }
    

    And test:

    a1.OnNext(true);
    a2.OnNext(true);
    a0.OnNext(true);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have these three (or more) lines that I want to surround with li
I have three tables in my DB (actually a few more than that) these
I have three (it's possible to have more than 3-4 generic list, but in
I have three checkboxes like ch[0], ch[1] and ch[3] (sometimes i have more, or
I have a array with a variable amount of values. Is there a more
This may be more of a best practice question. I have three views (create/details/edit)
How can i have three or more select tags with same names(as in my
I have three div's next to eachother, but when the content of one or
I have three or more independent variables represented as R vectors, like so: A
I have three big header files (4.5MB and more), with huge static arrays inside.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.