Skip to content

Instantly share code, notes, and snippets.

@testshallpass
Last active December 19, 2019 14:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save testshallpass/6c6c867269348c485a1e0d6ae3f55e90 to your computer and use it in GitHub Desktop.
Save testshallpass/6c6c867269348c485a1e0d6ae3f55e90 to your computer and use it in GitHub Desktop.
DropdownHolder Example #2
type AlertType = 'info' | 'warn' | 'error' | 'success'
export type DropdownType = {
alertWithType: (type: AlertType, title: string, message: string) => void
}
export class DropDownHolder {
static dropDown: DropdownType
static setDropDown(dropDown: DropdownType) {
this.dropDown = dropDown
}
static alert(type: AlertType, title: string, message: string) {
this.dropDown.alertWithType(type, title, message)
}
}
// ...
// then call
DropDownHolder.alert('error', 'Title', 'error message')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment