Proppy vue

Vue.js integration with ProppyJS

Version: 1.3.1 Updated: 04/14/2019

By: fahad19 License: MIT

Downloads Last 30 Days: 84

Install

npm i proppy-vue
yarn add proppy-vue

Repository: https://github.com/fahad19/proppy

CDNs

bundle.run: https://bundle.run/proppy-vue

jsDelivr: https://cdn.jsdelivr.net/npm/proppy-vue

unpkg: https://unpkg.com/proppy-vue

proppy-vue

npm

React integration package for ProppyJS


Guide

Installation

With npm:

$ npm install --save proppy vue proppy-vue

Via unpkg CDN:

<script src="https://unpkg.com/proppy@latest/dist/proppy.min.js"></script>
<script src="https://unpkg.com/proppy-vue@latest/dist/proppy-vue.min.js"></script>

<script>
  // available as `window.ProppyVue`
</script>

Usage

Render your Vue.js app with providers data:

// index.js
import Vue from 'vue';

import MyComponent from './components/MyComponent';

const providers = {
  foo: 'foo value',
};

const app = new Vue({
  provide: {
    proppy: providers,
  },

  render(h) {
    return <MyComponent />;
  },
});

Now anywhere from your components tree, you can use the attach higher-order component:

// components/MyComponent.js
import { compose, withProps } from 'proppy';
import { attach } from 'proppy-vue';

const P = compose(
  withProps((props, providers) => ({
    foo: providers.foo,
  })),
  withProps({ bar: 'bar value' }),
);

const MyComponent = {
  name: 'MyComponent',

  props: ['foo', 'bar'],

  render(h) {
    const { foo, bar } = this;

    return <p></p>;
  },
};

export default attach(P)(MyComponent);

API

attach

attach(P)(Component)

Higher-order component for attaching your Proppy factory to your Component.

Categories: Vue js
Tags: proppy