Giter VIP home page Giter VIP logo

vue-wonderpush's Introduction

vue-wonderpush

This service lets you integrate Wonderpush in your Vue applications easily.

Features

Installation and Quick Start

1- Installation:

You can install the module from a package manager of your choice directly from the command line

# Yarn
yarn add vue-wonderpush

# NPM
npm i vue-wonderpush

2- In your application

<template>
  <div id="app">
    <h1>Connecting to wonderpush</h1>
    <WonderPush v-bind="options">
      <!-- YOUR APP HERE -->
    </WonderPush>
  </div>
</template>

<script>
import {WonderPush} from 'vue-wonderpush'
export default {
  name: 'App',
  components : {
    WonderPush,
  },
  data: function(){
    return {
      options: {
        webKey: "YOUR KEY HERE",
      }
    }
  }
}
</script>

Options available for wonderpush.init: https://wonderpush.github.io/wonderpush-javascript-sdk/latest/WonderPush.html#.InitOptions

3- In your components

Integrate a wonderpush subscription:

<template>
  <div className="switch-container">
    <div id="wonderpush-subscription-switch" data-on="YES" data-off="NO"></div>
  </div>
</template>

<script>
  export default {
    name: 'SwitchButton',
  }
</script>

Create a component who need wonderpush:

import Wonderpush from 'vue-wonderpush';
<template>
  <div 
      v-bind:class= "['event', 'myEvent']"
      v-on:click="fireEvent()"
    > 
    Click this div to track "myEvent"
  </div>
</template>

<script>
  export default {
    props: [
      "wonderPush"
    ],
    methods: {
      fireEvent: function(){
        this.$props.wonderPush.trackEvent(this.$props.event)
      }
    }
  }
</script>

Give the wonderpush object on the import:

<template>
  <EventToTrack/>
</template>

<script>
  import EventToTrack from './EventToTrack'
  import {withWonderPush} from 'vue-wonderpush'

  export default {
    name : 'ParentOfEventToTrack',
    components: { EventToTrack: withWonderPush(EventToTrack, {waitWonderPushReady: true}) }
  }
</script>

WithWonderPush take two arguments:

  • Component
  • options

Options available:

  • waitWonderPushReady: boolean (default : false)

Sample app

To help you with your implementaiton we provided a sample application. to run it

cd wonderpush-sample-app
yarn start

then go to http://localhost:8080

License

This module is released under the permissive MIT License. Your contributions are always welcome.

Development

Start the wonderpush-sample-app with npm start or yarn start will install and build library and install sample-app node_modules if they not exists.

After forking you will need to run the following from a command line to get your environment setup:

  1. yarn install

After install you have the following commands available to you from a command line:

  1. gulp

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.