This adds a #sample method to Property that allows a Property to be sampled using an input Stream. This essentially allows for declarative polling of a Property. For instance, you could poll some text on a clock tick event and write it out:
message.sample(clock_tick).on_value do |value|
puts message
end
One nice little note is that it actually allows a 'discrete' Stream to be converted to a 'continuous' Property and then back again:
Coverage remained the same when pulling 244d543133eae0dbb8c1f9f46b2f54fb0e4fc889 on seadowg:prop_sample into f786b39ca12683b7c8ea61bd0474e84b2c10e572 on steveklabnik:master.
This adds a
#sample
method to Property that allows a Property to be sampled using an input Stream. This essentially allows for declarative polling of a Property. For instance, you could poll some text on a clock tick event and write it out:One nice little note is that it actually allows a 'discrete' Stream to be converted to a 'continuous' Property and then back again:
This is kind of silly but its also a nice example of the FRP world all coming together.