Skip to content

Commit

Permalink
Default Unit (#15)
Browse files Browse the repository at this point in the history
* updates api to have default millisecond unit, CI builds docs and examples

* adds ToUnit alias
  • Loading branch information
andrewMacmurray authored Mar 1, 2021
1 parent 32cd033 commit 354cf93
Show file tree
Hide file tree
Showing 8 changed files with 1,861 additions and 420 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/tests.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Integration Tests
name: Run Tests, Verify Docs and Examples

on:
push:
Expand All @@ -9,7 +9,7 @@ on:
- main

jobs:
run-tests:
verify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -25,4 +25,6 @@ jobs:
restore-keys: ${{ runner.os }}-elm-

- run: npm ci
- run: npm run test
- run: npm run test
- run: npm run docs:verify
- run: npm run examples:build
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ node_modules
# build
dist
tests/program/index.js
docs.json

# editor
.idea
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ To trigger a single update after a period of time pass `Delay.after` as a comman
```elm
FirstMessage ->
( model
, Delay.after 500 Millisecond SecondMessage
, Delay.after 500 SecondMessage
)
```

Expand All @@ -31,9 +31,9 @@ After triggering `FirstMessage`, `500ms` later update will be called with `Secon
Trigger ->
( model
, Delay.sequence
[ ( 1000, Millisecond, FirstMessage )
, ( 2000, Millisecond, SecondMessage )
, ( 1000, Millisecond, ThirdMessage )
[ ( 1000, FirstMessage )
, ( 2000, SecondMessage )
, ( 1000, ThirdMessage )
]
)
```
Expand All @@ -50,9 +50,9 @@ As a convenience if you'd only like to start a sequence if the model is in a par
Trigger ->
( model
, Delay.sequenceIf (not model.updating)
[ ( 1000, Millisecond, FirstMessage )
, ( 2000, Millisecond, SecondMessage )
, ( 1000, Millisecond, ThirdMessage )
[ ( 1000, FirstMessage )
, ( 2000, SecondMessage )
, ( 1000, ThirdMessage )
]
)
```
Expand All @@ -62,11 +62,11 @@ If you'd like all the steps to have the same unit of time, use the `Delay.withUn
```elm
Trigger ->
( model
, Delay.sequence <|
Delay.withUnit Millisecond
[ ( 1000, FirstMessage )
, ( 2000, SecondMessage )
, ( 1000, ThirdMessage )
, Delay.sequence
Delay.withUnit Delay.seconds
[ ( 1, FirstMessage )
, ( 2, SecondMessage )
, ( 1, ThirdMessage )
]
)
```
14 changes: 6 additions & 8 deletions examples/src/Main.elm
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,12 @@ init =
cycleColors : Model -> Cmd Msg
cycleColors model =
Delay.sequenceIf (not model.colorCycling)
(Delay.withUnit Delay.Millisecond
[ ( 0, ColorCycling True )
, ( 0, Red )
, ( 2000, Green )
, ( 2000, Blue )
, ( 2000, ColorCycling False )
]
)
[ ( 0, ColorCycling True )
, ( 0, Red )
, ( 2000, Green )
, ( 2000, Blue )
, ( 2000, ColorCycling False )
]



Expand Down
Loading

0 comments on commit 354cf93

Please sign in to comment.