How to use @cycle/most-run - 7 common examples

To help you get started, we’ve selected a few @cycle/most-run 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 goodmind / cycle-telegram / test / integration / plugins / most.ts View on Github external
{
      type: Update,
      name: 'not-found',
      component: ({ props }) => {
        t.fail(`wrong command \`${props[0]}\``)
      }
    }
  ]
  let main = (s: Sources) => ({
    bot: most.from([
      matchStream(s.bot.events('message').filter(entityIs('bot_command')), plugins, s)
        .map((x: Sources) => x.bot)
        .join()
    ])
  })
  let { sources, run } = Cycle(main, { bot: basicDriver })

  run()
  okTake(t, sources, (message) => {
    t.ok(Message.is(Message(message)), 'message satisfies typecheck')
    t.ok(
      /\/(help)(?:@goodmind_test_bot)?(\s+(.+))?/.test(message.reply_to_message.text),
      'reply to message text should match `/help` command pattern')
    t.equal(
      message.text,
      'Cycle Telegram v1.1.1 (https://git.io/vrs3P)',
      'message text should be equal to `Cycle Telegram v1.1.1 (https://git.io/vrs3P)`')
    t.end()
  })
})
github goodmind / cycle-telegram / test / integration / index / most.ts View on Github external
test('should get chat with basic driver', t => {
  let basicDriver = makeTelegramDriver(ACCESS_TOKEN, { skipUpdates: true })
  let main = () => ({
    bot: most.from([
      most.of(getChat({ chat_id: GROUP_ID }, {}))
    ])
  })
  let { sources, run } = Cycle(main, { bot: basicDriver })

  run()
  okTake(t, sources, (chat) => {
    t.ok(Chat.is(Chat(chat)), 'chat satisfies typecheck')
    t.equal(chat.id, GROUP_ID)
    t.end()
  })
})
github milankinen / culli / examples / sum / index.js View on Github external
import {run} from "@cycle/most-run"
import DOM from "@culli/dom"
import Store, {Memory} from "@culli/store"
import Sum, {nextId} from "./Component"

const N = 100
const sliders =
  Array.apply(0, Array(N)).map(() => ({id: nextId(), val: Math.floor(10 + Math.random() * 80) }))

run(Sum, {
  DOM: DOM("#app"),
  Store: Store(Memory({items: sliders}))
})
github fiatjaf / stack-forum / client / main.js View on Github external
import Cycle from '@cycle/most-run'
import {makeDOMDriver} from '@motorcycle/dom'
import {makeGraphQLDriver, gql} from 'cycle-graphql-most-driver'
import {makeNotificationDriver} from 'cycle-notification-most-driver'
import {makeStorageDriver} from 'cycle-storage-most-driver'
import ROUTER from 'cycle-hashrouter-most-driver'

import app from './app'

Cycle.run(app, {
  DOM: makeDOMDriver('#main', [
    require('snabbdom/modules/props'),
    require('snabbdom/modules/style')
  ]),
  GRAPHQL: makeGraphQLDriver({
    endpoint: '/graphql',
    templates: {
      fetchThreads: gql`
query fetchThreads {
  threads {
    id
    messages(order: "DESC") {
      text
      owner {
        name
      }
github aronallen / cycle-sandbox / sample / main.ts View on Github external
'./widget.js',
        { DOM: sources.DOM },
        ['DOM'],
        {
          DOM: DOMMainConnector
        }
      ).DOM).concat(sub.DOM)))
    .switch()

  return {
    DOM: vdom$,
    HTTP: sub.HTTP
  };
};

run(Component, {
  HTTP: makeHTTPDriver(),
  DOM : makeDOMDriver('#app'),
  Sandbox: makeSandboxDriver()
});
github frptools / collectable / packages / list / visualiser / index.js View on Github external
(function() {
  Cycle.run(main, {
    DOM: makeDOMDriver('#app-root')
  });

  setTimeout(() => {
    function firstView(arg) {
      return arg instanceof View ? arg : firstActiveView(arg);
    }
    function firstActiveView(state) {
      return state._left.isNone() ? state.right : state._left;
    }
    function commitToRoot(state) {
      var worker = TreeWorker.defaultPrimary().reset(state, firstActiveView(state), state.group, 2);
      while(!worker.isRoot()) {
        worker.ascend(2);
      }
    }
github motorcyclejs / motorcyclejs / dom / perf / dbmon / main.ts View on Github external
])
}

function main (sources: any) {
  return {
    DOM: sources.databases.map(mainMap)
  }
}

function load (stream: Subject) {
  stream.next(ENV.generateData().toArray())
  Monitoring.renderRate.ping()
  setTimeout(function () { load(stream) }, ENV.timeout)
}

Cycle.run(main, {
  DOM: makeDOMDriver('#test-container'),
  databases: function () {
    const stream = subject()
    load(stream)
    return stream
  }
})

@cycle/most-run

The Cycle run() function to be used with most.js

MIT
Latest version published 5 years ago

Package Health Score

68 / 100
Full package analysis

Popular @cycle/most-run functions