pandastrike / fairmont

Functional (and) reactive programming library for JavaScript.
ISC License
49 stars 8 forks source link

Add a reactive systems example? #50

Open dyoder opened 9 years ago

dyoder commented 9 years ago

Since Mutual/ng provides a simple event emitter interface for Redis-based messaging, we can set up a flow to implement a synchronized counter quite trivially.

Client

In the following code ,messages is a Mutual event-emitter.

go [
  events "update", messages
  map (counter) -> data.counter = counter
]
Server
go [
  observe data.counter
  map ({counter}) -> messages.emit "update", counter
]
dyoder commented 9 years ago

Work has begun in examples/messaging branch.