vue#UnwrapRef TypeScript Examples

The following examples show how to use vue#UnwrapRef. 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: useHistory.ts    From vhook with MIT License 6 votes vote down vote up
export function useHistory(): IHistoryResult {
  const state: UnwrapRef<IHistoryState> = reactive(buildState())
  const [, clearPopStateListener] = useEvent('popstate', buildState)
  const [, clearPushStateListener] = useEvent('pushstate' as any, buildState)
  const [, clearReplaceStateListener] = useEvent('replacestate' as any, buildState)
  const clear = () => {
    clearPopStateListener()
    clearPushStateListener()
    clearReplaceStateListener()
  }
  return {
    ...toRefs(state),
    clear
  }
}
Example #2
Source File: index.ts    From elenext with MIT License 5 votes vote down vote up
MENU_IJK: InjectionKey<UnwrapRef<MenuState>> = Symbol('Menu')
Example #3
Source File: index.ts    From elenext with MIT License 5 votes vote down vote up
SELECTDROPDOWN_IJK: InjectionKey<UnwrapRef<SelectDropdownState>> = Symbol('SelectDropdown')
Example #4
Source File: use-state.ts    From fect with MIT License 5 votes vote down vote up
useState = <T>(initial?: T) => {
  const state = ref<T | undefined>(initial)
  const dispatch = (next: SetStateAction<T>) => {
    const draft = typeof next === 'function' ? (next as (prevState: T) => T)(state.value as T) : next
    state.value = draft as UnwrapRef<T>
  }
  return [readonly(state), dispatch] as [DeepReadonly<Ref<T>>, Dispatch<T>]
}
Example #5
Source File: Store.ts    From universal-model-vue with MIT License 5 votes vote down vote up
private readonly reactiveState: T extends Ref ? T : UnwrapRef<T>;