npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-cycle

v0.1.2

Published

Cycle.js integration for Vue components

Downloads

9

Readme

VueCycle

Build Status A Vue plugin for injecting Cycle.js apps, batteries included.

Features

  • A vue-rx style directive for DOM events
  • A custom, testable DOM source for Vue components
  • Injected helper methods that make writing Cycle-style components easier

Usage

Install: npm install vue-cycle (Please note this plugin is still in development)

Installing plugin

VueCycle is available as a global plugin with very minimal configuration:

import VueCycle from 'vue-cycle'

Vue.use(VueCycle, {
  directive: 'xstream'
})

Composing VueCycle

If you do not want to install VueCycle as a global plugin, you can compose and use parts of the plugin you want instead:

import { VueCycleDOMMixin, VueCycleRunMixin, VueCycleDomDirective } from 'vue-cycle'

export default {
  mixins: [VueCycleDOMMixin, VueCycleRunMixin],
  directives: {
    xstream: VueCycleDomDirective
  }
}

Writing VueCycle Components

The jist of what VueCycle does is that it injects a DOM driver, and a few convenience methods that makes writing Cycle-styled components possible.

<template>
  <p>Current value is: {{ value }}</p>
  <button v-xstream:click="{ name: 'increment', data: count + 1 }">
    Increment
  </button>
</template>
<script>
export default {
  name: 'example',
  data() {
    return {
      count: 42
    }
  },
  $_cycle_app(sources) {
    const increment$ = sources.DOM.on('increment')
      .map(({ event, data }) => {
        // Where `event` is the original `click` event, and data is the
        // value passed to the directive
        return data
      })

    const state$ = increment$
      .map(newValue => {
        this.count = newValue

        return {
          count: this.count
        }
      })

    return {
      state: state$
    }
  },
  $_cycle_run(app) {
    run(app, {
      DOM: this.$domDriver,
      state: state$ => state$.addListener({
        next: () => {
          // Empty example stub to make sure `state$` side-effects are run
          // How you decide to handle state management is up to you =)
        }
      })
    })
  }
}
</script>

VueCycle injects a custom xstream directive that is used for identifying events on the custom DOM driver. See the directive documentation for more information.

The methods $_cycle_app and $_cycle_run are a core part of VueCycle where $_cycle_app if where you can define your primary component logic and $_cycle_run is where you perform the side-effects. You can here make use of HOCs that do not inject to the DOM, such as cycle-onionify.

API

VueCycle consists of multiple components:

  • VueCycleDOMMixin mixin
  • VueCycleRunMixin mixin
  • VueCycleDomDirective directive
  • fromCustomEvent injected method
  • watchProp injected method

VueCycleDOMMixin

Injects the $domDriver instance to the Vue component on created.

$domDriver

The injected DOM driver instance

on(eventName)

Params:

  • string eventName - Source event name

Return:

  • Stream Injected stream from xstream directive

VueCycleRunMixin

Runs the $_cycle_run function with injected $_cycle_app on mounted.

VueCycleDomDirective

The VueCycle xstream directive

The directive can be used the following ways:

  • v-xstream:$event="'$sourceName'"
  • v-xstream:$event="{ name: '$sourceName', data: 'some_value' }"

Where $event is the name of the DOM or Vue custom event, and $sourceName being the name of the event that will be used for filtering in the DOM driver.

fromCustomEvent(eventName)

An xstream wrapper for vm.$on events

Params:

  • string eventName - Name of the custom event

Return:

  • Stream xstream instance of custom event

watchProp(propName)

An xstream wrapper for vm.$watch events

Params:

  • string propName - Name of property to observe

Return:

  • Stream xstream instance of watched property