Chron's avatar
Level 7

Expose an empty function to overrride

Can I do something like this so I pass an empty function so I can override it from other places?

// useComposable.js

export default function useComposable() {
	const doSomethingFunction = () => {}
	
	const anotherFunction = async() => {
		await doSomethingFunction();
		console.log('do another thing after...')
	}

	return { doSomethingFunction }
}
// Parent
const { doSomethingFunction } = useComposable();

doSomethingFunction = () => {
	console.log('overriden function, do something');
}
0 likes
0 replies

Please or to participate in this conversation.