Skip to content

Instantly share code, notes, and snippets.

@dallinbeutler
Created July 17, 2019 23:30
Show Gist options
  • Save dallinbeutler/4c47b0e78e1f98c48011959c5abe88c5 to your computer and use it in GitHub Desktop.
Save dallinbeutler/4c47b0e78e1f98c48011959c5abe88c5 to your computer and use it in GitHub Desktop.
An Idea for dispatching Elmish events via a scrubbable timeline
//It all depends on where i call what the return shoud be...
// unit would be easiest with preapplied dispatcher
type Disp= unit->unit
//type Disp= unit->msg
type Event(dispatch:Disp, elapsedTime: int64 )=
member this.Msg = dispatch
member this.Time = elapsedTime
member this.Equals (obj) = false
interface System.IComparable with
member this.CompareTo(obj): int =
int (this.Time - elapsedTime)
static member ExecIfPast elapsed (event:Event) = if event.Time < elapsed then event.Msg(); true else false
let advanceTime (timelayer: Event list ) (newElapsed:int64) =
timelayer |> List.skipWhile (Event.ExecIfPast newElapsed)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment