How to use the mithril/stream.merge function in mithril

To help you get started, we’ve selected a few mithril 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 ArthurClemens / polythene / packages / test-tabs / src / components / onChange.js View on Github external
oninit: vnode => {
    const tab = stream({});
    Object.assign(vnode.state, {
      tab,
      redrawOnUpdate: stream.merge([tab]) // for React
    });
  },
  view: vnode => {
github ArthurClemens / polythene / packages / test-slider / src / components / onChange.js View on Github external
oninit: vnode => {
    const value = stream(attrs.defaultValue || attrs.value || 0);
    Object.assign(vnode.state, {
      value,
      redrawOnUpdate: stream.merge([value]) // for React
    });
  },
  view: vnode => {
github ArthurClemens / polythene / packages / test-menu / src / components / opener.js View on Github external
oninit: vnode => {
    const show = stream(false);
    Object.assign(vnode.state, {
      show,
      redrawOnUpdate: stream.merge([show]) // for React
    });
  },
  view: vnode => {
github ArthurClemens / polythene / packages / test-drawer / src / components / navigation.js View on Github external
oninit: vnode => {
      const show = stream(false);
      Object.assign(vnode.state, {
        show,
        redrawOnUpdate: stream.merge([show]) // for React
      });
    },
    view: vnode => {
github ArthurClemens / polythene / packages / test-spinner / src / components / opener.js View on Github external
oninit: vnode => {
    const show = stream(false);
    Object.assign(vnode.state, {
      show,
      redrawOnUpdate: stream.merge([show]) // for React
    });
  },
  view: vnode => {
github ArthurClemens / polythene / packages / test-menu / src / components / exposed.js View on Github external
oninit: vnode => {
    const show = stream(false);
    const selectedIndex = stream(0);
    Object.assign(vnode.state, {
      show,
      selectedIndex,
      redrawOnUpdate: stream.merge([show]), // for React
      id: "id-" + vnode.attrs.id || new Date().getTime() + Math.floor(Math.random() * 1000)
    });
  },
  view: ({ state, attrs }) => {
github ArthurClemens / polythene / packages / test-search / src / components / results.js View on Github external
} else if (e.key === "Enter") {
          e.preventDefault();
          selectedValue(matches()[index]);
        } else if (e.key === "Escape" || e.key === "Esc") { // "Esc" for IE11
          e.preventDefault();
          selectedListIndex(-1);
        }
      };

      Object.assign(vnode.state, {
        handleKey,
        selectedListIndex,
        matches,
        searchValue,
        selectedValue,
        redrawOnUpdate: stream.merge([searchValue, selectedListIndex]) // for React
      });
    },
    view: vnode => {
github ArthurClemens / polythene / packages / test-spinner / src / components / progress-opener.js View on Github external
const percentage = stream(0);
    const step = timestamp => {
      if (!start()) start(timestamp);
      const progress = timestamp - start();
      percentage(Math.min(1, 1.0 / STEP_DURATION * progress));
      if (h.redraw) h.redraw(); // update Mithril
      if (progress < STEP_DURATION) {
        window.requestAnimationFrame(step);
      }
    };
    Object.assign(vnode.state, {
      start,
      show,
      step,
      percentage,
      redrawOnUpdate: stream.merge([show, start, percentage]) // update React
    });
  },
  view: vnode => {
github ArthurClemens / polythene / packages / test-radio-button / src / components / radio-group.js View on Github external
oninit: vnode => {
    const checkedValue = stream(groupOptions.defaultCheckedValue || undefined);
    vnode.state = {
      checkedValue,
      redrawOnUpdate: stream.merge([checkedValue])
    };
  },
  view: vnode => {
github catarse / catarse / catarse.js / legacy / src / vms / project-vm.ts View on Github external
import h from '../h';
import models from '../models';
import rewardVM from './reward-vm';
import projectGoalsVM from './project-goals-vm';
import userVM from './user-vm';
import Stream from 'mithril/stream';
import { ProjectDetails } from '../entities';

const currentProject = prop(),
    userDetails = prop(),
    subscriptionData = prop(),
    projectContributions = prop([]),
    vm = catarse.filtersVM({ project_id: 'eq' }),
    idVM = h.idVM;

prop.merge([currentProject, userDetails, subscriptionData, projectContributions]).map(() => {
    h.redraw();
});

const isSubscription = (project = currentProject) => {
    if (_.isFunction(project)) {
        return project() ? project().mode === 'sub' : false;
    }

    return project ? project.mode === 'sub' : false;
};

const fetchSubData = projectUuid => {
    const lproject = commonAnalytics.loaderWithToken(models.projectSubscribersInfo.postOptions({ id: projectUuid }));

    lproject.load().then(data => {
        subscriptionData(