← Back to all articles

Latch design pattern in Rx

I just ran into some blog posts about the "latch design pattern".

http://www.minddriven.de/index.php/technology/development/design-patterns/latch-design-pattern

http://codebetter.com/blogs/jeremy.miller/archive/2007/07/02/build-your-own-cab-12-rein-in-runaway-events-with-the-quot-latch-quot.aspx

For those not yet using the Rx Framework, here is how you would do this;

var latch = new BehaviorSubject<bool>(false);

latch.CombineLatest(someEvent, (isLatched, args) => new {isLatched, args})
.Where(t => !t.isLatched)
.Select(t => t.args)

More soon...

Comments