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

bik

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bik

Simple functional components for non-choo & choo environments

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

bik

Simple functional components for non-choo & choo environments. Provides a state around morfine.

Installation

npm i bik

Example

var component = require('bik')
var html = require('nanohtml')

var counter = component({ count: 0 }, function (ctx, amount) {
  return html`
    <div onclick="${click}">Count is ${ctx.count}</div>
  `

  function click () {
    ctx.count += amount
    ctx.r()
  }
})

// non-choo
document.body.appendChild(counter())

// choo
html`${counter(2)}`

It also works standalone in the browser by including build/bik.min.js. It provides a global bik function.

Why?

To write simple components and be able to use them outside of Choo.

Bik's philosophy:

  • Support both choo and non-choo environments
  • Direct access to the whole context (state + component)
  • No events, only functions

API

render(...props) = bik(initialState, renderer(context, ...props))

Initialize a new bik instance. initialState is an object. The renderer function gets the whole context (state + component) as an argument, followed by the arguments of the render call.

component.load(el)

Called when the element was mounted via on-load.

component.unload(el)

Called when the element was unmounted via on-load.

component.rerender() or component.r()

Rerenders the component.

component.beforerender(el)

Called after the new tree has been generated, but not yet rendered.

component.afterrender(el)

Called after the new tree was rendered.

component.el

The current DOM Node in the document.

See Also

FAQs

Package last updated on 03 Mar 2019

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