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

Generate #11

Open
mattpodwysocki opened this issue Feb 16, 2014 · 4 comments
Open

Generate #11

mattpodwysocki opened this issue Feb 16, 2014 · 4 comments

Comments

@mattpodwysocki
Copy link
Contributor

Should we switch from using Procs ala this for Observable::generate?:

RX::Observable.generate(
    0,
    Proc.new { |x| return x <= 3 },
    Proc.new { |x| return x + 1 },
    Proc.new { |x| return x },
    scheduler)

to this style?

Observable.generate do
  initial_state 0
  condition {|x| x <= 3}
  result_selector {|x| x + 1}
  iterator {|x| x }
  scheduler RX::TestScheduler.new
end

# OR

Observable.generate do
  initial_state 0
  iterate_while {|x| x <= 3}
  select_result_with {|x| x + 1}
  iterate_with {|x| x }
  scheduler RX::TestScheduler.new
end
@aglover
Copy link

aglover commented Jun 4, 2014

I definitely prefer the newer style and I like the 2nd generate with iterate_with, etc.

@sunnyrjuneja
Copy link

There's a lot more clarity with the second example and much more succintness with the first. I personally prefer the succintness.

@wuest
Copy link
Contributor

wuest commented Mar 30, 2015

I might suggest a style that fits more closely e.g. with how Enumerators behave:

Observable.generate(0, RX::TestScheduler.new)
  .iterate { |x| x } # Identity as iterator could be the default
  .while   { |x| x <= 3 }
  .select  { |x| x + 1 }

@jredville
Copy link
Contributor

I prefer that last one. Giving a fluid interface to the whole thing

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

5 participants