Skip to content

Commit

Permalink
restoring synchronous behavior with new syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Harding committed Sep 16, 2024
1 parent 490bddc commit 06d3728
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/components/inputs/utils/useBoundValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,19 @@ import { computed } from "vue";

/**
* This function returns a computed variable for use with v-model, binding harness-vue store attributes to inputs.
* We use this instead of binding directly to the store so that we are dispatching actions which may have subscriptions
* We use this instead of binding directly to the store so that we can intercept and enforce the "synchronous" behavior in the "set"
* This also allows us to use getFilter/setFilter, which we have listeners on for beforeSet/afterSet behavior
* @param {Object} props Component Props
* @param {Object} harness the harness instance
* @returns {any} a vue computed
*/
export default function useBoundValue(props, harness) {
return computed({
get() {
try {
return harness.getFilter(props.filter.key);
} catch {
return null;
}
return harness.getFilter(props.filter.key);
},
set(value) {
harness.setFilter(props.filter.key, value);
harness.setFilter(props.filter.key, value, !props.synchronous);
},
});
}

0 comments on commit 06d3728

Please sign in to comment.