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

cyclic-fire

v2.0.2

Published

Yet another cyclejs driver for Firebase

Downloads

14

Readme

cyclic-fire

Yet another Cycle.js driver for the awesome BaaS Firebase.

"I didn't like the others, they were too flat"

Overview

There are three actual drivers in this package, you can use any or all of them as you wish:

  • makeAuthDriver gives you a source stream of auth states that are the result of the onAuth handler from the firebase library. It consumes a sink of objects that describe auth operations (login, logout)

  • makeFirebaseDriver is a read-only driver that gives you a source function that you can call to hook into a stream of updates from a path or query against your firebase. Internally, it caches these streams so that multiple calls to the same location or query wont create multiple streams.

  • makeQueueDriver is (currently) a write-only driver that consumes a sink of objects that get written to a specific location on your firebase. It is intended to be used with FirebaseQueue handling writes to your firebase on a backend somewhere.

Contributions

Development is driven by in-house developers at the Sparks.Network. Public participation (up to and including pull requests) are welcome.

Example of Use

Taken from sparks-cyclejs

Building the drivers

Pass any of the drivers you want to use a regular old firebase reference. Commonly this will be the root of your FB instance, but it doesn't have to be.

makeQueueDriver also accepts two optional parameters, the names of paths within the root you pass that are used for the input and output of the queue.

// in your main...
import {run} from '@cycle/core'
import {makeDOMDriver} from 'cycle-snabbdom'

import Firebase from 'firebase'

import {
  makeAuthDriver, makeFirebaseDriver, makeQueueDriver,
} from 'cyclic-fire'

import Root from './root'

const fbRoot = new Firebase('http://sparks-development.firebaseio.com')

const {sources, sinks} = run(Root, {
  DOM: makeDOMDriver('#root'),
  firebase$: makeFirebaseDriver(fbRoot),
  auth$: makeAuthDriver(fbRoot),
  // responses and tasks are actually defaults if you don't specify
  queue$: makeQueueDriver(fbRoot.child('!queue'),'responses','tasks'),
})

Using the Sources and Sinks

// in a component...
import {Observable} from 'rx'
import combineLatestObj from 'rx-combine-latest-obj'

import {div} from 'cycle-snabbdom'

import ProjectForm from 'components/ProjectForm'

// TODO: move to helpers/dom
const rows = obj =>
  Object.keys(obj).map(k => ({$key: k, ...obj[k]}))

const renderProjects = projects =>
  rows(projects).map(({name}) => div({}, [name]))

const _DOM = ({projects, formDOM}) =>
  div({}, [
    formDOM,
    div({},renderProjects(projects)),
  ])

export default sources => {
  // args passed to firebase driver describe a path or query on your firebase
  const projects$ = sources.firebase('Projects')
    .startWith([])

  const projectForm = ProjectForm(sources)

  // the new 
  const newProject$ = Observable.combineLatest(
      sources.auth$, projectForm.project$,
      (auth, project) => ({...project, uid: auth && auth.uid})
    )

  // within _DOM, projects will contain the contents of 'Projects'
  const DOM = combineLatestObj({projects$, formDOM$: projectForm.DOM}).map(_DOM)

  return {
    DOM,
    queue$: newProject$,
  }
}