All Projects â†’ PulsarBlow â†’ aurelia-firebase

PulsarBlow / aurelia-firebase

Licence: MIT license
🔥 A Firebase plugin for Aurelia

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to aurelia-firebase

movielist
A demo application built using Aurelia.io to search for and list movies
Stars: ✭ 17 (-29.17%)
Mutual labels:  aurelia
aurelia-knockout
Adds support for Knockout binding syntax to make transition from Durandal and Knockout to Aurelia simpler.
Stars: ✭ 22 (-8.33%)
Mutual labels:  aurelia
aurelia-virtual-scroll
Aurelia Virtual Scroller
Stars: ✭ 15 (-37.5%)
Mutual labels:  aurelia
Aurelia-Bootstrap-Plugins
Aurelia-Bootstrap-Plugins are Custom Elements to bridge with a set of 3rd party Bootstrap addons
Stars: ✭ 45 (+87.5%)
Mutual labels:  aurelia
northwind-demo
Breeze demo with .NET and NodeJS servers and Angular, Aurelia, React, and Vue clients
Stars: ✭ 23 (-4.17%)
Mutual labels:  aurelia
Aurelia-in-Action
Source code listings for Aurelia in Action
Stars: ✭ 19 (-20.83%)
Mutual labels:  aurelia
bindable
A design system built in Aurelia JS that allows for faster and easier web development.
Stars: ✭ 20 (-16.67%)
Mutual labels:  aurelia
aurelia-mdc-bridge
Aurelia Mdc Bridge is a collection of wrappers for Material Design Components.
Stars: ✭ 19 (-20.83%)
Mutual labels:  aurelia
aurelia-form
Fun with forms! Form utilities to make stuff just a bit (a lot) easier.
Stars: ✭ 34 (+41.67%)
Mutual labels:  aurelia
aurelia-cli-electron-app
A basic example of aurelia (cli) running in electron with vscode breakpoint debugging
Stars: ✭ 30 (+25%)
Mutual labels:  aurelia
aurelia-notify
A notification plugin for Aurelia.
Stars: ✭ 14 (-41.67%)
Mutual labels:  aurelia
super-minimal-aurelia
A barebones Aurelia + webpack2 build
Stars: ✭ 19 (-20.83%)
Mutual labels:  aurelia
Aurelia-styleguide
Aurelia Style Guide: A starting point for Aurelia development teams to provide consistency through best practices. http://aurelia.io
Stars: ✭ 24 (+0%)
Mutual labels:  aurelia
aurelia-mdc-plugin
MDC (Material Design UI Components) plugin for Aurelia.
Stars: ✭ 13 (-45.83%)
Mutual labels:  aurelia
aurelia-mdc-web
Aurelia wrapper for Material Design (Web) Components
Stars: ✭ 43 (+79.17%)
Mutual labels:  aurelia
aurelia-mdl-plugin
Material Design Lite plugin for Aurelia.
Stars: ✭ 19 (-20.83%)
Mutual labels:  aurelia
aurelia-typescript-boilerplate
A starter kit for building a standard navigation-style app with Aurelia, typescript and webpack by @w3tecch
Stars: ✭ 18 (-25%)
Mutual labels:  aurelia
aurelia-hacker-news
A recreation of the Hacker News website written in TypeScript and built with Aurelia.
Stars: ✭ 60 (+150%)
Mutual labels:  aurelia
aurelia-hoc-store
An Aurelia application showing the use of higher order components and a single state approach.
Stars: ✭ 20 (-16.67%)
Mutual labels:  aurelia
aurelia-open-id-connect
An aurelia adapter for the IdentityModel/oidc-client-js
Stars: ✭ 54 (+125%)
Mutual labels:  aurelia

aurelia-firebase

Circle CI Join the chat at https://gitter.im/aurelia/discuss

A Firebase plugin for Aurelia that supports Authentication, Reactive data collections (auto-sync) and other Firebase features. This plugin has been developed from scratch in order to provide an ubiquitous aurelia's experience and a Promise/A+ support.

This is an early version which comes with :

  • A complete firebase password authentication support.
  • A reactive collection providing auto-sync with Firebase server.

Roadmap for the next versions :

  • Full Query support (order, startAt, endAt etc..)
  • Priorities
  • Transactions
  • Third party authentications (Google, FB etc..)

###Demo

Aurelia on Fire is a demo app providing complete working implementation of the plugin features.

Play with the demo : https://aureliaonfire.azurewebsites.net
Check the demo source : https://github.com/PulsarBlow/aureliaonfire

Installation

Install via JSPM

Go into your project and verify it's already npm install'ed and jspm install'ed. Now execute following command to install the plugin via JSPM:

jspm install aurelia-firebase

this will add the plugin into your jspm_packages folder as well as an mapping-line into your config.js as:

"aurelia-firebase": "github:pulsarblow/[email protected]",

If you're feeling experimental or cannot wait for the next release, you could also install the latest version by executing:

jspm install aurelia-firebase@master

Migrate from aurelia-app to aurelia-app="main"

You'll need to register the plugin when your aurelia app is bootstrapping. If you have an aurelia app because you cloned a sample, there's a good chance that the app is bootstrapping based on default conventions. In that case, open your index.html file and look at the body tag.

<body aurelia-app>

Change the aurelia-app attribute to aurelia-app="main".

<body aurelia-app="main">

The aurelia framework will now bootstrap the application by looking for your main.js file and executing the exported configure method. Go ahead and add a new main.js file with these contents:

export function configure(aurelia) {
  aurelia.use
    .standardConfiguration()
    .developmentLogging();

  aurelia.start().then(a => a.setRoot('app', document.body));
}

Load the plugin

During bootstrapping phase, you can now include the plugin:

export function configure(aurelia) {
  aurelia.use
    .standardConfiguration()
    .developmentLogging()
    .plugin('aurelia-firebase'); //Add this line to load the plugin

  aurelia.start().then(a => a.setRoot('app', document.body));
}

#Configuration ##One config to rule them all The firebase plugin has one global configuration instance, which is passed to an optional callback function when you first install the plugin:

export function configure(aurelia) {
  aurelia.use
    .standardConfiguration()
    .developmentLogging()
    .plugin('aurelia-firebase', (config) => {
      config.setFirebaseUrl('https://myapp.firebaseio.com/');
    });

  aurelia.start().then(a => a.setRoot('app', document.body));
}

Note: if you want to access the global configuration instance at a later point in time, you can inject it:

import {Configuration} from 'aurelia-firebase';
import {inject} from 'aurelia-framework';

@inject(Configuration)
export class MyViewModel {
  _config = null;
  constructor(config)
  {
    this._config = config;
    console.log('My Firebase URL %s', this._config.getFirebaseUrl());
  }
}

##Possible configuration

Note: all these can be chained

(config) => { 
  config
    .setFirebaseUrl('https://myapp.firebaseio.com/')
    .setMonitorAuthChange(true);
}

####setFirebaseUrl(firebaseUrl: string)

Sets the Firebase URL where your Firebase data live. This is required and the plugin will not start if not provided.

(config) => {
  config.setFirebaseUrl('https://myapp.firebaseio.com/');
}

####setMonitorAuthChange(monitorAuthChange: boolean)

When set to true, the authentication manager will monitor authentication changes for the current user The default value is false.

(config) => { config.setMonitorAuthChange(true); }

#AuthenticationManager

The authentication manager handles authentication aspects of the plugin. Currently it is only supporting the password authentication flow but other authentication types are coming soon.

Below is an example implementation of a signin view model from the AureliaOnFire sample app.

import {inject} from 'aurelia-framework';
import {Router} from 'aurelia-router';
import {AuthenticationManager} from 'aurelia-firebase';

@inject(AuthenticationManager, Router)
export class SignIn {
  email = null;
  password = null;
  message = null;

  constructor(authManager:AuthenticationManager, router:Router) {
    this.authManager = authManager;
    this.router = router;
  }

  signIn() {
    this.message = null;
    this.authManager.signIn(this.email, this.password)
      .then(() => {
        this.router.navigateToRoute('accountIndex');
      })
      .catch((e) => {
        this.message = e.message;
      });
  }
}

AuthenticationManager documentation

#ReactiveCollection

The ReactiveCollection class handles firebase data synchronization.
To use it you just create a new ReactiveCollection passing its constructor the firebase data location relative to the Firebase Url you provided at the plugin initialization.

// My data location is at http://myapp.firebaseio.com/posts
let myCollection = new ReactiveCollection('posts');

// My data location is at http://myapp.firebaseio.com/users/john/posts
let myCollection = new ReactiveCollection(['users', 'john', 'posts']);

Your collection is now synchronized to your firebase data location. Any change happening either side will be synchronized on the other side.

From there you can use your ReactiveCollection :

let myCollection = new ReactiveCollection(['users', 'john', 'posts']),
    post = {
	  subject: 'This is my post subject',
	  content: 'A super coool post content'
    };

myCollection.add(post);
myCollection.remove(post);

ReactiveCollection exposes an items property which is synchronized with your firebase data. You can use this property in your views databindings:

<div class="row au-stagger">
  <div class="au-animate" repeat.for="item of collection.items">
    <p>${item.subject}</p>
    <p>${item.content}</p>
  </div>
</div>

ReactiveCollection documentation

#Events Publisher

Beside monitoring the user authentication state changes internally (with these changes exposed through the currentUser property), the AuthManager also triggers application wide events. It uses the aurelia's EventAggregator to do so.

Events Publisher documentation

Sample implementation

Check the sample implementation at : https://github.com/PulsarBlow/aureliaonfire While we work on a better documentation, this is a great place to learn about the plugin features.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].