vue#isProxy TypeScript Examples
The following examples show how to use
vue#isProxy.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: traverse.ts From S2 with MIT License | 6 votes |
traverse = <T>(value: T, seen?: Set<T>) => {
// eslint-disable-next-line dot-notation
if (!isObject(value) || (value as any)['__v_skip']) {
return value;
}
if (!isProxy(value) && !isRef(value)) {
return value;
}
seen = seen || new Set();
if (seen.has(value)) {
return value;
}
seen.add(value);
if (isRef(value)) {
traverse(value.value, seen);
} else if (isArray(value)) {
for (let i = 0; i < value.length; i++) {
traverse(value[i], seen);
}
} else if (isSet(value) || isMap(value)) {
value.forEach((v: any) => {
traverse(v, seen);
});
} else if (isPlainObject(value)) {
for (const key in value as any) {
traverse((value as any)[key], seen);
}
}
return value;
}
Example #2
Source File: useSheetUpdate.ts From S2 with MIT License | 5 votes |
useSheetUpdate = (
s2Ref: ShallowRef<SpreadSheet | undefined>,
props: BaseSheetProps,
) => {
const updateFlag = reactive({
rerender: false,
reloadData: false,
rebuildDataset: false,
});
watch(
() => props.options,
(options, prevOptions) => {
updateFlag.rerender = true;
if (!Object.is(prevOptions?.hierarchyType, options?.hierarchyType)) {
// 自定义树目录需要重新构建 CustomTreePivotDataSet
updateFlag.reloadData = true;
updateFlag.rebuildDataset = true;
}
s2Ref.value?.setOptions(options as S2Options);
s2Ref.value?.changeSheetSize(options?.width, options?.height);
},
{ deep: isProxy(props.options) },
);
watch(
() => props.dataCfg!,
(dataCfg) => {
updateFlag.rerender = true;
updateFlag.reloadData = true;
s2Ref.value?.setDataCfg(dataCfg);
},
{ deep: isProxy(props.dataCfg) },
);
watch(
() => props.themeCfg!,
(themeCfg) => {
updateFlag.rerender = true;
s2Ref.value?.setThemeCfg(themeCfg);
},
{
deep: isProxy(props.themeCfg),
},
);
watch(updateFlag, (flag) => {
if (!flag.rerender) {
return;
}
s2Ref.value?.render(flag.reloadData, {
reBuildDataSet: flag.rebuildDataset,
});
flag.rerender = false;
flag.reloadData = false;
flag.rebuildDataset = false;
});
}