Created
March 25, 2017 21:30
-
-
Save anacrolix/99556345bd716f3ac5c0de2884af42e4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module StaleUpdater exposing (..) | |
type alias StaleUpdater = | |
{ stale : Bool | |
, updating : Bool | |
} | |
new : StaleUpdater | |
new = | |
{ stale = False | |
, updating = False | |
} | |
setStale : StaleUpdater -> StaleUpdater | |
setStale su = | |
{ su | stale = True } | |
startingUpdate : StaleUpdater -> StaleUpdater | |
startingUpdate su = | |
{ updating = True, stale = False } | |
needUpdate : StaleUpdater -> Bool | |
needUpdate su = | |
su.stale && not su.updating | |
updatedOk : StaleUpdater -> StaleUpdater | |
updatedOk su = | |
{ su | updating = False } | |
updateFailed : StaleUpdater -> StaleUpdater | |
updateFailed su = | |
{ stale = True, updating = False } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment