bara
Created For Creating - Create any JavaScript application.
Last updated 14 days ago by nampdn .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install bara 
SYNC missed versions from official npm registry.

Bara

Bara is a library created for creating any (front/back/cli) JavaScript application.

Installation

npm install --save bara

or

yarn add bara

Usage

Full Application

const {
  register,
  useStream,
  useTrigger,
  useEvent,
  useCondition,
  useAction,
  createEventType
} = require('bara')

const ON_TIME_ESLAPSED = createEventType('ON_TIME_ESLAPSED')

const EVERY_X_SECOND = x => second => second % x === 0
const ONLY_EVEN_SECOND = EVERY_X_SECOND(2)

const app = () => {
  // Register source stream factory for Bara application
  useStream(({setName, addEventType, emit}) => {
    setName('dev.barajs.timer')

    let elapsed = 0;
    const timer = setInterval(() => {
        emit(ON_TIME_ESLAPSED, elapsed++);
    }, 1000);

    return () => {
        // Cleanup when zero listener
        clearInterval(timer)
    }
  })

  // Register a trigger that will be triggered every even second
  useTrigger(() => {
    const event = useEvent(ON_TIME_ESLAPSED)
    const condition = useCondition(ONLY_EVEN_SECOND)
    const action = useAction((second) => {
      console.log(`Tik every even seconds: ${second}`)
    })

    return {event, condition, action}
  })

  // Register a trigger that will be triggered every 5 second
  useTrigger(() => {
    const every = 5
    const event = useEvent(ON_TIME_ELAPSED)
    const condition = useCondition(EVERY_X_SECOND(every))
    const action = useAction((second) => {
      console.log(`Tik every `${every}` seconds: ${second}`)
    })

    return {event, condition, action}
  })
}

register(app);

Current Tags

  • 2.0.1-alpha.14                                ...           canary (5 months ago)
  • 2.5.0                                ...           latest (14 days ago)
  • 2.0.0                                ...           next (5 months ago)

22 Versions

  • 2.5.0                                ...           14 days ago
  • 2.4.0                                ...           4 months ago
  • 2.3.2                                ...           4 months ago
  • 2.3.1                                ...           4 months ago
  • 2.3.0                                ...           4 months ago
  • 2.2.0                                ...           4 months ago
  • 2.1.0                                ...           5 months ago
  • 2.0.1-alpha.14                                ...           5 months ago
  • 2.0.0                                ...           5 months ago
  • 1.2.0                                ...           6 months ago
  • 1.1.10                                ...           6 months ago
  • 1.1.9                                ...           6 months ago
  • 1.1.8                                ...           6 months ago
  • 1.1.7                                ...           6 months ago
  • 1.1.6                                ...           6 months ago
  • 1.1.5                                ...           6 months ago
  • 1.1.4                                ...           6 months ago
  • 1.1.3                                ...           6 months ago
  • 1.1.2                                ...           6 months ago
  • 1.1.1                                ...           6 months ago
  • 0.1.0                                ...           a year ago
  • 0.0.1                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 18
Last Day 0
Last Week 1
Last Month 66
Dependencies (3)
Dev Dependencies (6)

Copyright 2014 - 2016 © taobao.org |