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

webix-firebase

v0.6.0

Published

Firebase adapter for Webix UI

Downloads

20

Readme

Firebase adapter for Webix UI

npm version

Library allows using Webix components with FireBase

Latest version will work with Webix 6.2+, if you are using an older version of Webix, you need to use version 0.5 of this package.

Citing the Firebase site:

When data changes, apps built with Firebase update instantly across every device -- web or mobile.

Firebase-powered apps work offline. Data is synchronized instantly when your app regains connectivity.

Firestore

Include Webix and Firebase files on the page

<!-- Webix -->
<script type="text/javascript" src="http://cdn.webix.com/edge/webix.js"></script>
<link rel="stylesheet" type="text/css" href="http://cdn.webix.com/edge/webix.css">
<!-- Webix-Firebase adapter -->
<script type="text/javascript" src="../codebase/webix-firestore.js"></script>
<!-- FireBase -->
<script src="https://www.gstatic.com/firebasejs/5.0.4/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/5.0.4/firebase-firestore.js"></script>

Create main firebase connection

firebase.initializeApp({
	apiKey: "YOU API KEY HERE",
	projectId: "webix-demo"
});

// create firebase connection, and assign it to webix
var db = firebase.firestore();
db.settings({ timestampsInSnapshots:true });

webix.firestore = db;

Init webix component, using "firebase->{reference}" as data url

webix.ui({
	id:"dtable",
	view:"datatable",
	autoConfig:true,

	// load data from "books" collection
	url: "firestore->books",
	// save data to "books" collection
	save:"firestore->books"
}

That is it.

Adding "url" property will enable data loading and automatic updates of component when data changed in the firebase.

Adding "save" property ensures that all changes in the datatable will be saved to the Firebase

Using FireBase references

Instead of using text url you can use firestore collections directly

firebase.initializeApp({
	apiKey: "YOU API KEY HERE",
	projectId: "webix-demo"
});

// create firebase connection, and assign it to webix
var db = firebase.firestore();
db.settings({ timestampsInSnapshots:true });

var proxy = webix.proxy("firestore", db.collection("books"));

webix.ui({
	view:"list",
	url: proxy,
	save: proxy
}););

Dynamic data loading

You can use "load" command to (re)load data in the component.

$$("dtable").clearAll();
$$("dtable").load("firestore->books");

or

$$("dtable").clearAll();
$$("dtable").load( webix.proxy("firestore", collection) );

Realtime Database

Include Webix and Firebase files on the page

<!-- Webix -->
<script type="text/javascript" src="http://cdn.webix.com/edge/webix.js"></script>
<link rel="stylesheet" type="text/css" href="http://cdn.webix.com/edge/webix.css">
<!-- Webix-Firebase adapter -->
<script type="text/javascript" src="../codebase/webix-firebase.js"></script>
<!-- FireBase -->
<script src="https://www.gstatic.com/firebasejs/5.0.4/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/5.0.4/firebase-database.js"></script>

Create main firebase connection

firebase.initializeApp({
  databaseURL: "https://webix-demo.firebaseio.com/"
});

// create firebase connection, and assign it to webix
webix.firebase = firebase.database();

Init webix component, using "firebase->{reference}" as data url

webix.ui({
	id:"dtable",
	view:"datatable",
	editable:true, editaction:"dblclick",
	columns:[{
		id:"name", editor:"text", fillspace:1
	},{
		id:"author", editor:"text", fillspace:1
	}],

	// load data from /books
	url: "firebase->books",
	// save data to /books
	save:"firebase->books"
}

That is it.

Adding "url" property will enable data loading and automatic updates of component when data changed in the firebase.

Adding "save" property ensures that all changes in the datatable will be saved to the Firebase

Using FireBase references

Instead of using text url you can use firebase references directly

firebase.initializeApp({
	databaseURL: "https://webix-demo.firebaseio.com/"
});
var db = firebase.database();
var proxy = webix.proxy("firebase", db.ref("books"));

webix.ui({
	view:"list",
	url: proxy,
	save: proxy
});

Dynamic data loading

You can use "load" command to (re)load data in the component.

$$("dtable").clearAll();
$$("dtable").load("firebase->books");

or

$$("dtable").clearAll();
$$("dtable").load( webix.proxy("firebase", ref) );

Sync api

Webix components have native sync api to sync data between components. The same api can be used with firebase

firebase.initializeApp({
	databaseURL: "https://webix-demo.firebaseio.com/"
});
webix.firebase = firebase.database();
var ref = webix.firebase.ref("books");

$$("dtable").sync(ref);

Working with Forms and Templates

Similar to data views, you can use "load" and "save" API while working with Forms

//form
$$("form").load("books/4");
...
$$("form").save();

//template
$$("template").load("books/4")

In some cases, it has sense to not load data correctly but bind form ( template ) to some other view or data collection

var data = new webix.DataCollection({
	url:"firebase->books",
	save:"firebase->books"
})
form.bind(data);
data.waitData.then(function(){
	//you need to use setCursor API to load some record from collection into a form
	data.setCursor("4");
})

or, the same for the datatable

webix.ui({
	view:"datatable", autoConfig:true, id:"d1", select:true,
	url:"firebase->books",
	save:"firebase->books"
});
form.bind("d1"); //selected row will be shown in a form

Samples

License

The MIT License

Copyright (c) 2015 Maksim Kozhukh

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.