Created
January 20, 2020 11:16
-
-
Save bitfishxyz/f90d12cbd2b5d355bab108fbe92d6831 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
const actions = ()=>{ | |
const functionA = ()=>{/*do sth*/} | |
const functionB = ()=>{/*do sth*/} | |
const functionC = ()=>{/*send log*/} | |
return new Map([ | |
[/^guest_[1-4]$/,functionA], | |
[/^guest_5$/,functionB], | |
[/^guest_.*$/,functionC], | |
//... | |
]) | |
} | |
const onButtonClick = (identity,status)=>{ | |
let action = [...actions()].filter(([key,value])=>(key.test(`${identity}_${status}`))) | |
action.forEach(([key,value])=>value.call(this)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment