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

vuec8

v0.0.4

Published

VueC8 bindings for Vue.js

Downloads

6

Readme

VueC8

Introduction

VueC8 is a small and pragmatic solution to create real time bindings between a Macrometa data platform (C8) and your Vue application. Making it straightforward to always keep your local data in sync with remotes databases.

Why

While JSC8 does provide an API to keep your local data in sync with any changes happening in the remote database, it is more tedious. Here is the code you need to write to keep your local state in sync with C8DB without using Vuec8. Let's take the example of binding a collection.

To explore more you can visit jsc8_tutorial

Fabric = require('jsc8')
fabric = new Fabric("MY-Macrometa-URL");
...
...
fabric.login(email, password)
          .then(() => {
}
...
...

new Vue({
	data: () => ({
		todo: []
	}),
	created() {
		fabric.query(`C8QL query`)
    		.then((cursor: ArrayCursor) => {
				this.todo= cursor
			});
		const subscription = fabric.collection('Collection Name');

		subscription.onchange({
			onmessage:function onchange(documentMsg){
				// Write logic here to manage the updated document
			}
		},
		URL);
		},
	//manage unsubscribe onDestroy.
})

Now let's look at the equivalent code with vuec8:

Vue.use(vuec8, {
        auth: {
		  email: 'EMAIL',
          password: 'PASSWORD',
        },
        config: 'URL OR CONFIG obj',
      })

new Vue({
	el: '#app',
	data: {
		todo: [],
	},
	c8db: {
		todo: 'collectionName',
	},
})

## Download and Install JavaScript Client

Installation

In order to get started make sure to install the latest version of vuec8

yarn add vuec8
## - or -
npm install vuec8

Or from source

git clone https://github.com/macrometacorp/vuec8.git
cd VueC8
npm install
npm run build

Plugin

VueC8 must be installed as a Vue plugin

import { vuec8 } from "vuec8";

Vue.use(vuec8, {
        auth: {
		  email: 'EMAIL',
          password: 'PASSWORD',
        },
        config: 'URL OR CONFIG obj',
      })

API

1. Plugin Options

{
  "auth": {
	"email": "EMAIL",
    "password": "PASSWORD",
  },
  "fabricName": "fabricName",
  "config": "url"
}
  • config : string or string[] or Config

2. Vue component Macrometa database (C8DB) is injected into your vue object, you can assign c8db a object or a function which returns a object. object keys should be same as the keys defined in your vue data object and the values should be of Type

string | {
      collection: string;
      filter?: Array<{
					  fieldPath: string;
					  opStr: "<" | "<=" | "==" | ">=" | ">";
					  value: any;
					}>;
      documentId?: string;
      fabricName?: string;
    }
  • fabricName If fabric name is not assigned it will use the fabricName assigned in Plugin options, if fabricName in plugin options is also not assigned it will take as default fabricName (_system)

  • filter will AND the conditions together. eg: [{//condition 1},{ //condition 2}] : FILTER condition 1 AND condition 2

  • documentId if documentId is assigned it will fetch a specific document in a collection.

new Vue{
...
	data:{
		todo:[],
	},
	c8db:{
		todo: "collection"
	},
...
}

or

new Vue{
...
	data:{
		todo:[],
	},
	c8db:{
		todo: {
		fabricName: "fabric",
		collection : "collection",
		filter:[{
					fieldPath: "value",
					opStr: "<",
					value: 5
			}]
		}
	},
...
}

3. c8Refs

  • vuec8 adds c8Refs in every component where c8db is initialized. c8Refs will have reference to you collection & fabric instance for the a every data key referenced in Macrometa platform. jsc8 has complete guide on fabric & collection instance.
new Vue{
...
	data:{
		todo:[],
	},
	c8db:{
		todo: "collection"
	},
	updated(){
	  // It can be used to handle customized behavior.
		this.$c8Refs.todo._collection // collection reference for todo
		this.$c8Refs.todo._fabric // fabric reference for tod
	},
...
}