Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

It's like something that does stuff

NotificationsYou must be signed in to change notification settings

athanclark/elm-every

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Repeatidly issue an action, with some time frame in-between.

It's pretty simple to integrate, all you need is:

  • a function to determine how much time to wait until the next issue, based onthe total time waited so far:Time -> Time
  • an action to issue, with some data it would expect to apply with

Then, to start the poller, you issueStart with some data you would want theaction to use. To update this data, just make another call toStart. Then,to stop the poller, just issueStop.

importEverytype aliasEveryState={ kickoffCount:Int}type aliasMyModel={ mySession:SessionModel, poller:Every.ModelEveryState}initMyModel:MyModelinitMyModel={ mySession= initSession, poller=Every.init}typeMyAction=SessionMsgSessionMsg|EveryMsg(Every.MsgEveryState)|KickStart-- we're calculating the time to add to the total, based on the current total.fibbDelay:MaybeEveryState->Time->TimefibbDelay_ total= totalissueMsg:MaybeEveryState->MsgissueMsgms=-- ...updateModel:MyAction->MyModel->(MyModel,CmdMyAction)updateModelaction model=caseactionofSessionMsg a->let(newSession, eff)= updateSession a model.mySessionin({ model| mySession= newSession},Cmd.mapSessionMsg eff)EveryMsg a->let(newEvery, eff)= updateEvery                              fibbDelay                              issueMsg                              a                              model.pollerin({ model| poller= newEvery},Cmd.map(\r->caserofErr x-> x-- resolve issued dataOk  x->EveryMsg x) eff)KickStart->( model,Task.perform(Debug.crash<< toString)EveryMsg<|Every.Start{ resetSoFar=True, modifyData=Just<|Every.Update<|\ms->casemsofNothing->{ kickoffCount=1}Just ks->{ kickoffCount= ks.kickoffCount+1}})

About

It's like something that does stuff

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp