How to use the @vue/composition-api.onBeforeMount function in @vue/composition-api

To help you get started, we’ve selected a few @vue/composition-api examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github davidkpiano / xstate / packages / xstate-vue / src / useMachine.ts View on Github external
if (state.changed) {
        current.value = state;
      }
    }
  );

  const initialState = rehydratedState
    ? State.create(rehydratedState)
    : service.initialState;

  const current = ref>(initialState);

  // extract send method for sending events to the service
  const send = (event: TEvent | TEvent['type']) => service.send(event);

  onBeforeMount(() => {
    service.start(rehydratedState ? initialState : undefined);
  });

  onBeforeUnmount(() => {
    service.stop();
  });

  return {
    current,
    service,
    send
  };
}
github vuejs / function-api-converter / src / functions / windowSize.js View on Github external
export function onWindowResize (callback) {
  onBeforeMount(() => {
    window.addEventListener('resize', callback)
  })
  onUnmounted(() => {
    window.removeEventListener('resize', callback)
  })
}
github metaspace2020 / metaspace / metaspace / webapp / src / modules / MolecularDatabases / DatabasesTable.tsx View on Github external
setup(props) {
    const state = reactive({
      showUploadDialog: false,
    })

    const { result, loading, refetch } = useQuery(
      getGroupDatabasesQuery,
      { groupId: props.groupId },
      { fetchPolicy: 'no-cache' },
    )

    onBeforeMount(refetch)

    const onDialogClose = () => {
      state.showUploadDialog = false
    }

    const onUploadComplete = () => {
      onDialogClose()
      refetch()
    }

    return () => (
      <div>
        <header class="flex justify-between items-center py-3">
          <div class="flex items-center">
            
            <p class="m-0 ml-1 text-sm leading-5 text-gray-700"></p></div></header></div>
github logaretm / vue-use-web / src / WindowScrollPosition.ts View on Github external
export function useWindowScrollPosition(options: WindowScrollOptions = { throttleMs: 100 }) {
  const x = ref(0);
  const y = ref(0);

  function setScrollPos() {
    x.value = window.pageXOffset;
    y.value = window.pageYOffset;
  }

  const onScroll = throttle(options.throttleMs, setScrollPos);

  onBeforeMount(() => {
    setScrollPos();
  });

  onMounted(() => {
    window.addEventListener('scroll', onScroll, { passive: true });
  });

  onUnmounted(() => {
    window.removeEventListener('scroll', onScroll);
  });

  return {
    x,
    y
  };
}
github logaretm / vue-use-web / src / WindowSize.ts View on Github external
export function useWindowSize(options: WindowSizeOptions = { throttleMs: 100 }) {
  const width = ref(0);
  const height = ref(0);

  function setSize() {
    width.value = window.innerWidth;
    height.value = window.innerHeight;
  }

  const onScroll = throttle(options.throttleMs, setSize);
  onBeforeMount(() => {
    setSize();
  });

  onMounted(() => {
    window.addEventListener('resize', onScroll, { passive: true });
  });

  onUnmounted(() => {
    window.removeEventListener('resize', onScroll);
  });

  return {
    height,
    width
  };
}