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

@highdeserttechnologies/client-pinia-vue-sdk

v2.0.10

Published

A wrapper of the client-entities interactions using Vue and its Pinia state management.

Downloads

33

Readme

@freakingreallyawesomenocode/client-pinia-vue-sdk

Overview

This package is an adapter which binds the FRANk change feeds / change streams to Vue and Pinia stores to assist in UI development

Usage

The SDK exports 4 items:

  • useEventActivityStore (The pinia store function for event activity)
  • useItemBiddingStore, (The pinia store function for item bidding activity)
  • EventRuntimePiniaVueSdk, (The main-level vue sdk that initializes and keeps the 2 above items up to date)
  • eventRuntimeApiSdk (The REST api singleton for writing data into the event runtime (ex: bidding))

Here is an example of how the sdk is instantiated:

import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue'
import { eventRuntimeApiSdk, EventRuntimePiniaVueSdk, useEventActivityStore, useItemBiddingStore } from '@freakingreallyawesomenocode/client-pinia-vue-sdk';

const BIDDING_SERVER_URL = 'http://localhost:4030';
const DELTA_SERVER_URL = 'ws://localhost:9001';

// NOTE: Pinia and the app must be attached prior to setup/initialization of the event runtime sdk
const pinia = createPinia();
const app = createApp(App, { BIDDING_SERVER_URL, DELTA_SERVER_URL });
app.use(pinia);
useEventActivityStore();
useItemBiddingStore();

const customAuthHeaderFn = async function(){
    return Promise.resolve({Authorization: 'Bearer jwt.token.here'});
}

// The api sdk allows the user to set an async customHeader function which will be applied for REST Api calls into the sdk.
eventRuntimeApiSdk.customHeaderFn = customAuthHeaderFn;
eventRuntimeApiSdk.baseBiddingUri = BIDDING_SERVER_URL;

const sdk = new EventRuntimePiniaVueSdk(BIDDING_SERVER_URL, DELTA_SERVER_URL);
await sdk.initialize();
await sdk.watchEvents(['event-10000', 'event-20000', 'event-30000']); 

app.mount('#app');

Reference

An example pinia item bidding store is below:

import { ref } from 'vue';
import { defineStore } from 'pinia';
import { applyPatch } from 'fast-json-patch';

export const useItemBiddingStore = defineStore('itemBiddingStore', () => {
    const items = ref({});

    function addItemBidding(itemBiddingModel) {
        this.items[itemBiddingModel.id] = itemBiddingModel;
    }

    function updateItemBidding(id, itemBiddingModel) {
        this.items[id] = itemBiddingModel;
    }

    function removeItemBidding(id) {
        delete this.items[id];
    }

    function applyJsonPatch(id, jsonPatch) {
        applyPatch(this.items[id], jsonPatch, false, true);
    }

    return {
        items,
        addItemBidding,
        updateItemBidding,
        removeItemBidding,
        applyJsonPatch
    }
})

Note that the contents of these stores match the datamodel that is in the database directly - no changes or mutation. The contents are also live updated/added as changes/inserts to the database are written.