Reactive watcher to load effect scopes dynamically depending on the watched value. Typically, the effect scope you load is a function that contains reactive logic in the same way you would have in a component setup function.
Example use:
const watchSource = ref(...) // anything
const composableReturnState = watchCreateEffectScope(watchSource, (watchValue) => {
/*
* This function is like a watcher callback. It gets called with the new value everytime the `watchSource` changes.
* You can execute whatever code you would normally execute in a component setup function. Everytime the `watchSource`
* value changes, all effects loaded previously gets disposed, and the callback function gets re-executed,
* loading any new effects.
*/
if (watchValue) {
return composable1();
} else {
return composable2();
}
});
// `composableReturnState` is a ref containing the state of the loaded effect.