Remove shared variable in search_settings.vue
Context
The following discussion from !53659 (merged) should be addressed:
-
@ealcantara started a discussion: (+1 comment) nitpick (non blocking): This is a very unlikely scenario but I wonder if creating the map instance in this place prevents us from having two instances of this component in the same context. Should we bind the lifecycle of this map to the component’s lifecycle?
Implementation Notes
Let's consider encapsulating the helper functions in a factory function that remembers the displayOptions
state. Something like:
const createSettingsSearcher = (displayOptions) => {
return {
// ...
};
};
export default {
created() {
// Not a data() since it can't / shouldn't be reactive
this.searcher = createSettingsSearcher({ ... });
}
methods: {
search(value) {
this.searchTerm = value;
if (value.length) {
this.searcher.saveExpansionState();
this.searcher.search(value);
} else {
this.searcher.restoreExpansionState();
}
},
},
}
/cc @ealcantara