Skip to content

Instantly share code, notes, and snippets.

@allanphilipbarku
Forked from bitfishxyz/cache.js
Created February 12, 2020 02:55
Show Gist options
  • Save allanphilipbarku/9e1aadf51645ea48a97bd5e1437c28de to your computer and use it in GitHub Desktop.
Save allanphilipbarku/9e1aadf51645ea48a97bd5e1437c28de to your computer and use it in GitHub Desktop.
const actions = ()=>{
const functionA = ()=>{/*do sth*/}
const functionB = ()=>{/*do sth*/}
return new Map([
[{identity:'guest',status:1},functionA],
[{identity:'guest',status:2},functionA],
[{identity:'guest',status:3},functionA],
[{identity:'guest',status:4},functionA],
[{identity:'guest',status:5},functionB],
//...
])
}
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