Skip to content

Instantly share code, notes, and snippets.

@bryanedds
Created November 6, 2014 16:05
Show Gist options
  • Save bryanedds/3f7d60169a8316835bfa to your computer and use it in GitHub Desktop.
Save bryanedds/3f7d60169a8316835bfa to your computer and use it in GitHub Desktop.
And yet somehow I'm confident that this will actually run properly the first time...
let product address (observable : 'a Observable) : ('a * 'b) Observable =
let subscribe = fun world ->
let subscriptionKey = World.makeSubscriptionKey ()
let subscriptionKey' = World.makeSubscriptionKey ()
let subscriptionAddress = !+ [acstring subscriptionKey]
let subscriptionAddress' = !+ [acstring subscriptionKey']
let (address', unsubscribe, world) = observable.Subscribe world
let unsubscribe = fun world ->
let world = unsubscribe world
let world = World.unsubscribe subscriptionKey world
World.unsubscribe subscriptionKey' world
let subscription = fun event world ->
let subscription' = fun event' world ->
let eventData = (event.Data, event'.Data)
let world = World.publish<'a * 'b> World.sortSubscriptionsNone subscriptionAddress subscriptionAddress eventData world
(Cascade, world)
let world = World.subscribe<'b> subscriptionKey' address' subscriptionAddress' subscription' world
(Cascade, world)
let world = World.subscribe<'a> subscriptionKey address subscriptionAddress subscription world
(subscriptionAddress, unsubscribe, world)
{ Subscribe = subscribe; TypeCarrier = fun (_ : 'a * 'b) -> () }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment