Launch Week Day 1: Socket for Jira Is Now Available.Learn More
Socket
Book a DemoSign in
Socket

effector-dom

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

effector-dom

Effector package for working with dom

latest
Source
npmnpm
Version
0.0.15
Version published
Weekly downloads
38
-13.64%
Maintainers
1
Weekly downloads
 
Created
Source

Effector-DOM

Declarative stack-based DOM api

Usage

import {createStore, createEvent} from 'effector'
import {using, spec, list, h} from 'effector-dom'

using(document.body, () => {
  const addLine = createEvent()
  const code = createStore(['let foo = 0']).on(addLine, list => [
    ...list,
    `foo += ${Math.random()}`,
  ])
  const color = createStore('cornsilk').on(addLine, color => {
    switch (color) {
      case 'cornsilk':
        return 'aliceblue'
      case 'aliceblue':
        return 'cornsilk'
    }
  })

  h('section', () => {
    spec({
      style: {
        backgroundColor: color,
        padding: '1em',
      },
    })
    list(code, ({store}) => {
      h('div', {text: store})
    })
  })
  h('section', () => {
    spec({data: {section: 'controls'}})
    h('button', {
      handler: {click: addLine},
      text: 'Add line',
      style: {padding: '1em'},
    })
  })
})

Component is just a plain function

function VizionSectionHeader(text) {
  h('header', () => {
    spec({data: {vizionSectionHeader: true}})
    h('h4', {
      text,
    })
  })
}

Try it

Keywords

state manager

FAQs

Package last updated on 11 Mar 2020

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