I would like to convert a function that return multiple functions, into a class with a constructor that should be called only with the new
keyword.
I tried this :
const toast = () => {
return ({
getToast: () => {
return 'toast'
},
setToast: () => {
return 'wtf'
}
})
}
class t {
constructor() {}
}
const t1 = t.bind(toast())
const tt = new t1()
console.log(tt.getToast)
But it print undefined
.
I also tried Object.assign(t, toast())
, or doing simply this = toast()
in the constructor but it doesn't work.