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

Tiny library for isolated web components

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

bik

Tiny library for isolated web components

installation

npm i -S bik

example

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

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

	function click() {
		t.count++
		t.r()
	}
})
counter.load = function (el) {
	el.innerHTML += ' (fresh!)'
}
counter.afterupdate = function (el) {
	el.innerHTML += ' (updated!)'
}

counter(document.body)

It should also work standalone in the browser by including build/bik.min.js.

why?

I love choo but sometimes you don't want to use it as the base of a site. For example when I want to use a single component (example: counter, list, responsive menu). It can also be used to build components as modules.

Uses nanomorph under the hood and you need nanohtml or something similar.

api

component(root) = bik(initialstate, handler(component))

Initialize a new bik instance. initialstate is an object that stores the default values for the variables used by the component. The handler function gets the component itself as an argument. component(root) appends the component to the root Node.

component.prepend(root)

Prepends the component to the root Node.

component.load(el)

Called when the element was mounted.

component.render() or component.r()

Rerenders the component.

component.afterupdate(el)

Called after the component was rerendered.

component.element

The component's DOM Node.

FAQs

Package last updated on 06 Feb 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