1.0.0 • Published 4 years ago

kanban-board-firebase v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

Kanban board firebase

This package helps you organize your Kanban board data using firebase.

Content

Installation

Using npm:

$ npm i kanban-board-firebase

Note: add `--save', if you use npm <5.0.0

Example

First you need to create a project and an application firebase.

Initialization

Pass apiKey, authDomain, projectId in initializeApp.(Firebase config object)

// api.js
import { initializeApp } from "kanban-board-firebase";

const { lane, card, db, app } = initializeApp({
    apiKey: FIREBASE.API_KEY,
    authDomain: FIREBASE.AUTH_DOMAIN,
    projectId: FIREBASE.PROJECT_ID
});

Now you can use lane and card as API.

import { lane } from "./api";

const getAllLanes = async () => {
    try {
       // ...
       const lanes = await lane.get();
       // ...   
    } catch (e) {
      // ...
    }
}

Lane methods

MethodDescription
get()Get all columns and cards of this user.
create()Add a column.
move()Change column position.
update()Change column title.
remove()Delete column.
Card methods
MethodDescription
create()Add a card.
move()Change card position.
update()Change card title.
remove()Delete card.

Authentication

The user information is saved locally in Firebase. It is not necessary to save the token. User will remain even after page refresh.

Registration

Password and login are required for registration.

import { signUp } from "kanban-board-firebase";

const signUpUser = async () => {
    try {
       // ...
        const user = await signUp({
            email: 'user@email.com', // user's email 
            password: '123456' // user's password   
        });
       // ...   
    } catch (e) {
      // ...
    }
}

Authorization

Password and login are required for authorization.

import { signIn } from "kanban-board-firebase";

const signInUser = async () => {
    try {
       // ...
        const user = await signIn({
            email: 'user@email.com', // user's email 
            password: '123456' // user's password   
        });
       // ...   
    } catch (e) {
      // ...
    }
}

To log out the user

import { signOut } from "kanban-board-firebase";

const signOutUser = async () => {
    try {
       // ...
        await signOut();
       // ...   
    } catch (e) {
      // ...
    }
}

Subscription to user information updates

You can subscribe to user information updates.

React.js example
import { useEffect } from 'react';
import { onAuthChanged } from 'kanban-board-firebase';

const App = () => {
    //...
    useEffect(() => {
        const unsubscriber = onAuthChanged((user) => {
            if (user) {
                // User is signed in.
            } else {
                // No user is signed in.
            }
        });

        return () => unsubscriber();
    }, []);
    //...
}
1.0.0

4 years ago