How to use mutant - 10 common examples

To help you get started, we’ve selected a few mutant examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Happy0 / ssb-chess / modules_core / app.js View on Github external
function app () {
    process.nextTick(() => insertCss(api.styles()))

    var view = Value(getView())
    var screen = h('App', view)

    window.onhashchange = () => view.set(getView())
    document.body.appendChild(screen)

    // tabs (another core module) currently handles this
    // window.addEventListener('error', window.onError = displayError)

    return screen
  }
github ticktackim / ticktack-workplan / message / obs / shares.js View on Github external
'message.obs.shares': (id) => {
      if (!ref.isLink(id)) throw new Error('an id must be specified')
      var obs = get(id)
      obs.id = id
      var result = computed(obs, getShares, {
        // allow manual append for simulated realtime
        onListen: () => activeShares.add(obs),
        onUnlisten: () => activeShares.delete(obs)
      })
      result.sync = obs.sync
      return result
    }
  })
github ticktackim / ticktack-workplan / message / obs / webshares.js View on Github external
'message.obs.webshares': (id) => {
      if (!ref.isLink(id)) throw new Error('an id must be specified')
      var obs = get(id)
      obs.id = id
      var result = computed(obs, getShares, {
        // allow manual append for simulated realtime
        onListen: () => activeShares.add(obs),
        onUnlisten: () => activeShares.delete(obs)
      })
      result.sync = obs.sync
      return result
    }
  })
github pietgeursen / patch-gatherings / gathering / html / location.js View on Github external
function location ({location, msg, isEditing, onUpdate}) {
    const markdown = api.message.html.markdown
    return h('div', {}, computed(location, markdown))
  }
}
github ticktackim / ticktack-workplan / app / html / context.js View on Github external
function Option ({ notifications = 0, imageEl, name, location, selected }) {
      return h('Option', { className: selected ? '-selected' : '' }, [
        h('div.circle', [
          when(notifications, h('div.alert', notifications)),
          imageEl
        ]),
        api.app.html.link(location, name),
      ])
    }
  })
github blockades / patchbay-dark-crystal / views / component / secret.js View on Github external
function renderSecret () {
    return [
      h('h1', 'Your secret'),
      when(secretLabel, [ h('h3', 'Label'), h('pre', secretLabel) ]),
      h('h3', 'Secret'),
      h('pre', secret),
      h('div.actions', [
        CopyToClipboard({ toCopy: secret }),
        when(modalOpen, h('button -subtle', { 'ev-click': () => modalOpen.set(false) }, 'close'), [])
      ])
    ]
  }
github pietgeursen / patch-gatherings / gathering / html / description.js View on Github external
function description ({description, isEditing, onUpdate}) {
    const markdown = api.message.html.markdown
    const input = h('textarea', {'ev-input': e => onUpdate(e.target.value), value: description})

    return h('Description', [
      when(isEditing,
        input,
        computed(description, markdown)
      )
    ])
  }
}
github pietgeursen / patch-gatherings / router / html / page / gathering.js View on Github external
function menuItem (handleClick) {
    return h('a', {
      style: { order: 1 },
      'ev-click': () => handleClick(route)
    }, route)
  }
github ticktackim / ticktack-workplan / message / html / compose.js View on Github external
function PreviewSetup (strings) {
      var showPreview = Value(false)
      var previewBtn = h('Button',
        {
          className: when(showPreview, '-strong', '-subtle'),
          'ev-click': () => showPreview.set(!showPreview())
        },
        when(showPreview, strings.blogNew.actions.edit, strings.blogNew.actions.preview)
      )
      return { previewBtn, showPreview }
    }
    var { previewBtn, showPreview } = PreviewSetup(strings)
github ticktackim / ticktack-workplan / app / html / lightbox.js View on Github external
return nest('app.html.lightbox', (content, isOpen) => {

    if (typeof isOpen !== 'function') isOpen = Value(false)

    const closeMe = () => isOpen.set(false)


    const lb = h('Lightbox', { className: when(isOpen, '-open', '-close'), 'ev-click': closeMe },
      h('div.content', {'ev-click': (ev) => ev.stopPropagation()},[
        content
      ]))

    lb.close = closeMe

    return lb
  })
}

mutant

Create observables and map them to DOM elements. Massively inspired by hyperscript and observ-*. No virtual dom, just direct observable bindings. Unnecessary garbage collection is avoided by using mutable objects instead of blasting immutable junk all ove

MIT
Latest version published 4 years ago

Package Health Score

45 / 100
Full package analysis