Last active
May 17, 2019 14:45
-
-
Save alshdavid/e74cf689b74928268fdff24e2eeb5caf 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
type Thing = { | |
data: string | |
printData: () => void | |
} | |
const printData = (t: Thing) => () => { | |
console.log(t.data) | |
} | |
const createThing = (): Thing => { | |
const state = { | |
data: 'hey' | |
} | |
return { | |
...state | |
printData: printData(state) | |
} | |
} | |
// Usage | |
const thing = createThing() | |
thing.printData() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment