Vuex 2 binding for Firebase 3, Strongly based on Vuefire

Vuex 2 binding for Firebase 3, Strongly based on Vuefire

FireVuex Vuex 2 binding for Firebase 3, strongly based on vuefire.

FireVuex

Vuex 2 binding for Firebase 3, strongly based on vuefire.

Installation

  1. If included as global <script>: the FireVuex will be available globally.

  2. In module environments, e.g CommonJS:

npm i -S firevuex

and then next

const FireVuex = require('firevuex')

Usage

You may want to see the example to have a preview of usage.

const app = firebase.initializeApp({ ... })
const store = new Vuex.Store({ ... })

// Binding
FireVuex.bindDatabase(store, app, {
  'message': 'message',
  'todos': { source: 'todos', type: 'array' },
  ...
})

Ways of binding

FireVuex.bindDatabase(store, app, dataMap)
  • store is a vuex store
  • app is a firebase app
  • dataMap is an object describing how refs and queries will be linked to the store modules as such:
{
  moduleNameOrPath: {
    source: QueryOrRefOrPath,
    type: 'array' | 'object',
    cancelCallback: ...
  }
}

But you can do it shorter moduleNameOrPath: QueryOrRefOrPath.

There are two types of bindings, the array binding for lists and object binding for the rest.

Object binding

A source bound as object with the name foobar will create a foobar module with a foobar/get getter returning the current value and a foobar/set action that can be used to change the value.

Array binding

A source bound as array with the name foobar will create a foobar module containing list of records that you can retrieve with the foobar/get getter.

Each record contain a .key property which specifies the key where the record is stored. So if you have data at /items/-Jtjl482BaXBCI7brMT8/, the record for that data will have a .key of "-Jtjl482BaXBCI7brMT8".

If an individual record's value in the database is a primitive (boolean, string, or number), the value will be stored in the .value property. If the individual record's value is an object, each of the object's properties will be stored as properties of the bound record.

There are three actions available foobar/add, foobar/remove and foobar/update, that will allow you to handle the list.

Contributing

Clone the repo, then:

$ npm install    # install dependencies
$ npm run dev    # watch and build dist/vuefire.js
$ npm run build  # build dist/vuefire.js and vuefire.min.js

Download Details:

Author: Granipouss

Source Code: https://github.com/Granipouss/firevuex

vuejs vue javascript

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

8 Popular Websites That Use The Vue.JS Framework

In this article, we are going to list out the most popular websites using Vue JS as their frontend framework. Vue JS is one of those elite progressive JavaScript frameworks that has huge demand in the web development industry. Many popular websites are developed using Vue in their frontend development because of its imperative features.

Vue Native is a framework to build cross platform native mobile apps using JavaScript

Vue Native is a framework to build cross platform native mobile apps using JavaScript. It is a wrapper around the APIs of React Native. So, with Vue Native, you can do everything that you can do with React Native. With Vue Native, you get

How to Make a Simple Vue Custom Select Component

In this article, you’ll learn how to build a Vue custom select component that can be easily be styled using your own CSS. In fact, it’s the same component that we use in production on Qvault, and you can see it in action on the playground.

Creating a Custom Tooltip Component in Vue

There are plenty of libraries out there that will have you up and running with a good tooltip solution in minutes. However, if you are like me, you are sick and tired of giant dependency trees that have the distinct possibility of breaking at any time.

Vue ShortKey plugin for Vue.js

Vue-ShortKey - The ultimate shortcut plugin to improve the UX .Vue-ShortKey - plugin for VueJS 2.x accepts shortcuts globaly and in a single listener.