How to use the mutant.computed function in mutant

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 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 / 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 ticktackim / ticktack-workplan / message / html / likes.js View on Github external
return nest('message.html.likes', function likes(msg) {
    var id = api.keys.sync.id()
    var likes = api.message.obs.likes(msg.key)

    var iLike = computed(likes, likes => likes.includes(id))
    var count = computed(likes, likes => likes.length ? likes.length : '')

    return h('Likes', { 'ev-click': () => publishLike(msg, !iLike()) }, [
      h('i.fa', { className: when(iLike, 'fa-heart', 'fa-heart-o') }),
      h('div.count', count)
    ])
  })
github blockades / patchbay-dark-crystal / views / component / secret.js View on Github external
function renderError () {
    return [
      h('h1', [ 'Error combining shards!!!' ]),
      h('pre', computed(error, e => (e || '').toString())),
      h('div.actions', [
        when(modalOpen, h('button -subtle', { 'ev-click': () => modalOpen.set(false) }, 'close'), [])
      ])
    ]
  }
}

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 5 years ago

Package Health Score

45 / 100
Full package analysis