Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

firestruct

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

firestruct

Minimal immutable Firebase API

  • 0.0.23
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Firestruct

Install:

npm install firestruct

Usage:

import Firestruct from "firestruct";

const count = c => c.value();
const increment = c => c.update(i => i + 1);

const fs = new Firestruct("https://test.firebaseio.com/clickcount");

fs.on("swap", (newCursor, oldCursor, path) => {
    const clicksCursor = newCursor.cursor("clicks");

    React.render(
        <ClickCount
            count={ count(clicksCursor) }
            onClick={ event => increment(clicksCursor) } />,
        document.body
    );
);

API:

Structure

on(eventName, callback)

Event handler. Provides callback with 3 arguments:

  • newCursor
  • oldCursor
  • changePath TODO

Events:

  • "swap": data change
structure._fb

Deprecated. Reference to raw Firebase object.

Please make note of any use; it should be unnecessary for all but Auth.

Cursor

Cursors are immutable references to the current structure.

cursor.cursor(path)

Returns a new cursor.

path is an array/string pointing to a child location.

cursor.value()

Returns the value of the current cursor

cursor.update(callback)

Replaces the value of the current cursor with the return value of callback. TODO: Returns the new cursor.

callback is provided with the current value of the cursor as the first argument.

  • New branches may be created by selecting a non-existant path, then calling update with some data.

  • Old branches may be deleted by selecting a path, then setting it as undefined.

cursor.cursors()

Convenience function. Returns an array of child [key, cursor] pairs.

cursor._fb

Deprecated. Reference to raw Firebase snapshot.

Please make note of any use; it should be unnecessary. Tree-climbing and current node keys will never be supported.

FAQs

Package last updated on 01 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc