Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
grainjs
Advanced tools
Readme
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.
npm install --save grainjs
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'),
'!',
),
);
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.
FAQs
JS library from Grist Labs
The npm package grainjs receives a total of 80 weekly downloads. As such, grainjs popularity was classified as not popular.
We found that grainjs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.