Skip to content

Instantly share code, notes, and snippets.

@reggi
Created November 27, 2019 03:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reggi/5f26649bc7e525a2a9f534b91ae2fa8b to your computer and use it in GitHub Desktop.
Save reggi/5f26649bc7e525a2a9f534b91ae2fa8b to your computer and use it in GitHub Desktop.
export function ServiceState<G>(): new () => { value?: G, set(type: G): G }
export function ServiceState<G>(type: G): new () => { value: G, set(type: G): G }
export function ServiceState<G>(type?: G) {
return class ServiceState {
value: G | undefined
constructor() {
this.value = type
}
set(type: G) {
this.value = type
return type
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment