Socket
Socket
Sign inDemoInstall

grainjs

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    grainjs

JS library from Grist Labs


Version published
Weekly downloads
112
decreased by-33.73%
Maintainers
1
Install size
947 kB
Created
Weekly downloads
 

Readme

Source

GrainJS

npm version Build Status

GrainJS is a Javascript (and TypeScript) library for building highly performant dynamic applications.

GrainJS provides convenient pure-JS interfaces for building DOM. It has observables inspired by Knockout to create declarative data models and tie them to UI. It includes light-weight event dispatching, DOM event subscriptions, disposable components, and in-code CSS styling.

GrainJS is in part inspired by React, but based on observables instead of virtual dom, and with a convenient way to build DOM without JSX. It is lighter weight, and has less magic happening under the covers.

The focus is on performance and conciseness. The library has no dependencies and is only 31K. minified.

Installation

npm install --save grainjs

Basic Example

const name = observable("");

dom.update(document.body,
  dom('input', {type: 'text', placeholder: 'Enter your name'},
    dom.on('input', (ev, elem) => name.set(elem.value)),
  ),
  dom('div', 'Hello, ',
    dom.text((use) => use(name).toUpperCase() || 'Stranger'),
    '!',
  ),
);

Documentation

At a basic level, GrainJS allows you to describe DOM structure in one place, using Javascript (or TypeScript), and to keep the dynamic aspects of it separated into variables called "observables". These observables serve as the model of the UI; other code can update them to cause UI to update, without knowing the details of the DOM construction.

In addition, the library provides approaches to create and dispose resources (important for long-lived single-page applications), and an assortment of other related tools.

Keywords

FAQs

Last updated on 05 Dec 2021

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc