9427686d42
* fix(fe2): unfollow on camera move * WIP new state hydration function * WIP sync state * minor cleanup * fix coloring not being tracked * fix for post thread close camera pos restore * supporting duplicate users * preventing guest commenting + state reset fixes * fixed guests not receiving viewer comment updates * post-thread creation opens new thread * removing gap between 'X is typing' and bubble appearing * reset filters will also reset colors now * fixed thread full context * camera reset fix * thread reset fix * fixed router concurrency issues * followed user avatar fix * TONS OF DEBUGGING FOR ROUTER QUEUING * removing queued routing debugging stuff + disabling spotlight cancelation * WIP async URL updates * missing authLogger fixed * fix for broken projection * fix for bubbles positions not updating correctly * queued routing cleanup * fixed spotlight mode disabling unnecessarily * added back stoplight stop on ctrl * undid spotlight debugging
31 lines
1008 B
TypeScript
31 lines
1008 B
TypeScript
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
import { MaybeAsync } from '@speckle/shared'
|
|
import { AsyncComputedOptions, computedAsync } from '@vueuse/core'
|
|
|
|
export interface AsyncWritableComputedOptions<T> {
|
|
get: (...args: any[]) => MaybeAsync<T>
|
|
set: (value: T) => MaybeAsync<void>
|
|
initialState: T
|
|
readOptions?: AsyncComputedOptions
|
|
}
|
|
|
|
export type AsyncWritableComputedRef<T> = ComputedRef<T> & {
|
|
update: AsyncWritableComputedOptions<T>['set']
|
|
}
|
|
|
|
/**
|
|
* Allows async read/write from/to computed. Use `res.value` to read and `res.update` to write. If you only need
|
|
* the computed to be read-only then use vueuse's `computedAsync`.
|
|
* @param params
|
|
*/
|
|
export function writableAsyncComputed<T>(
|
|
params: AsyncWritableComputedOptions<T>
|
|
): AsyncWritableComputedRef<T> {
|
|
const readValue = computedAsync(params.get, params.initialState, params.readOptions)
|
|
|
|
const getter = computed(() => readValue.value) as AsyncWritableComputedRef<T>
|
|
getter.update = params.set
|
|
|
|
return getter
|
|
}
|