Skip to content

Instantly share code, notes, and snippets.

@bitfishxyz
Created January 20, 2020 11:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bitfishxyz/dbb7b7fbd2a477e63807cdc806f9d2fe to your computer and use it in GitHub Desktop.
Save bitfishxyz/dbb7b7fbd2a477e63807cdc806f9d2fe to your computer and use it in GitHub Desktop.
const actions = new Map([
[{identity:'guest',status:1},()=>{/*do sth*/}],
[{identity:'guest',status:2},()=>{/*do sth*/}],
//...
])
const onButtonClick = (identity,status)=>{
let action = [...actions].filter(([key,value])=>(key.identity == identity && key.status == 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