Created
August 14, 2020 01:51
-
-
Save naush/3f5c2d191c34a71b4acbf41b5af837db to your computer and use it in GitHub Desktop.
This file contains 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
enum WishState { | |
PENDING = 1, | |
STARTED = 2, | |
FULFILLED = 3, | |
}; | |
const forward = (state: WishState) => { | |
switch (state) { | |
case WishState.PENDING: | |
return WishState.STARTED; | |
case WishState.STARTED: | |
return WishState.FULFILLED; | |
default: | |
return WishState.PENDING; | |
} | |
} | |
const backward = (state: WishState) => { | |
switch (state) { | |
case WishState.FULFILLED: | |
return WishState.STARTED; | |
case WishState.STARTED: | |
return WishState.PENDING; | |
default: | |
return WishState.PENDING; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment