npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dozerjs/dozer-vue

v0.0.6

Published

<div align="center"> <a target="_blank" href="https://getdozer.io/"> <br><img src="https://dozer-assets.s3.ap-southeast-1.amazonaws.com/logo-blue.svg" width=40%><br> </a> </div>

Downloads

10

Readme

Overview

This repository is a vue helpers for using Dozer as data provider.

Installation

# npm
npm install @dozerjs/dozer-vue
# yarn
yarn add @dozerjs/dozer-vue
# pnpm
pnpm add @dozerjs/dozer-vue

Usage

Provider

<script setup lang="ts">
import { DozerProvider } from "@dozerjs/dozer-vue";
</script>

<template>
  <DozerProvider :value="{
      serverAddress: 'http://localhost:50051',
  }">
    <!-- content -->
  </DozerProvider>
</template>

query

useDozerQuery(endpoint: string, query?: DozerQuery)

This hook can be used for getting data from cache. It allows to pass query. Query is json object serialized as string.

<script setup lang="ts">
import { useDozerQuery } from "@dozerjs/dozer-vue";
const { fields, records } = useDozerQuery('airports');
</script>

<template>
  <div v-for="record of records" :key="record.__dozer_record_id">{{JSON.stringify(record)}}</div>
</template>

count

useDozerCount(endpoint: string, query?: DozerQuery)

This hook returns number of records in endpoint.

<script setup lang="ts">
import { useDozerCount } from "@dozerjs/dozer-vue";
const { count } = useDozerCount('airports');
</script>

<template>
  <span>Total airports count: {count}</span>
</template>

event

useDozerEvent(options: DozerOnEventOption[])

This hook can create a gRPC stream to monitor real-time store modifications for multiple endpoints.

<script setup lang="ts">
import { types_pb } from '@dozerjs/dozer';
import { useDozerEvent } from "@dozerjs/dozer-vue";
import { ref } from 'vue';

const count = ref(0);

const { stream } = useDozerEvent([
  {
    endpoint: 'airports',
    eventType: types_pb.EventType.All,
  }
]);

stream.on('data', (operation: types_pb.Operation) => {
  count.value += 1;
})
</script>

<template>
  <span>Total event count: {count}</span>
</template>

Advantage

connect stream

Here a connect function exported from useDozerQuery and useDozerCount, it can monitor gRPC stream exported from useDozerEvent and automagically updates.

<script setup lang="ts">
import { types_pb } from '@dozerjs/dozer';
import { useDozerCount, useDozerEvent, useDozerQuery } from "@dozerjs/dozer-vue";

const { stream } = useDozerEvent([
  {
    endpoint: 'airports',
    eventType: types_pb.EventType.ALL
  },
]);
const { count, connect: countConnect } = useDozerCount('airports');
const { records, connect: queryConnect } = useDozerQuery('airports');
countConnect(stream);
queryConnect(stream);
</script>

<template>
  <h3>Total count: <small>* automagic updates</small></h3>
  <div>{count}</div>
  <h3>Records length:  <small>* automagic updates</small></h3>
  <div v-for="record of records" :key="record.__dozer_record_id">{{JSON.stringify(record)}}</div>
</template>

consume operation

The connect function will consume all the operations of gRPC stream, if you want to filter, you can use consume funtion.

<script setup lang="ts">
import { types_pb } from '@dozerjs/dozer';
import { useDozerCount, useDozerEvent, useDozerQuery } from "@dozerjs/dozer-vue";

const { stream } = useDozerEvent([
  {
    endpoint: 'airports',
    eventType: types_pb.EventType.ALL
  },
]);
const { count, consume: countConsume } = useDozerCount('airports');
const { records, consume: queryConsume } = useDozerQuery('airports');
stream.on('data', (operation: types_pb.Operation) => {
  countConsume(operation);
  queryConsume(operation);
});
</script>

<template>
  <h3>Total count: <small>* automagic updates</small></h3>
  <div>{count}</div>
  <h3>Records length:  <small>* automagic updates</small></h3>
  <div v-for="record of records" :key="record.__dozer_record_id">{{JSON.stringify(record)}}</div>
</template>

multiple endpoints with event

useDozerEndpoints(options: DozerOnEventOption[])

This hook can get data for multiple endpoints. Can also automagic updates if you set eventType.

<script setup lang="ts">
import { types_pb } from '@dozerjs/dozer';
import { useDozerEndpoints } from "@dozerjs/dozer-vue";

const options = [
  {
    endpoint: 'airports',
    eventType: types_pb.EventType.ALL
  },
  {
    endpoint: 'airports_count',
    eventType: types_pb.EventType.All,
  },
];
const data = useDozerEndpoints(options);
</script>

<template>
  <div v-for="(option, index) in options">
    <h3>{{ option.endpoint }}</h3>
    <div v-if="data[index]">
      <div v-for="record of records" :key="record.__dozer_record_id">{{JSON.stringify(record)}}</div>
    </div>
  </div>
</template>