Reputation: 10264
My code:
export default (function () {
(...)
return {
open: () => {
(...)
},
close: () => {
(...)
},
get: () => {
(...)
}
}
})();
I wanna call the close()
in get()
function like this :
get: () => {
close();
}
I tried to use this
but it doesn't work.
Please give me some advice.
Thank you in advance.
Upvotes: 6
Views: 561
Reputation: 370679
Either use method properties instead (for which this
rules will work just like with standard non-arrow functions):
export default (function () {
(...)
return {
open() {
(...)
},
close(){
(...)
},
get() {
(...)
this.close();
}
}
})();
Or define all functions that you want to be able to cross-reference before the return
statement:
export default (function () {
(...)
const close = () => {
(...)
};
return {
open: () => {
(...)
},
close,
get: () => {
(...)
close();
}
}
})();
Upvotes: 10