4.15.1-alpha.29 • Published 6 years ago

@mycure/sdk-vue v4.15.1-alpha.29

Weekly downloads
1
License
MIT
Repository
-
Last release
6 years ago

Mycure sdk-web Vue bindings

Installation

$ cd <project-directory>>
$ yarn add vue vuex vue-router firebase @mycure/{sdk,sdk-vue}

Usage

import Vue from 'vue';
import Vuex from 'vuex';
import VueRouter from 'vue-router';
import sdk from '@mycure/sdk-vue';

const store = new Vuex();
const router = new VueRouter();

// initialize the sdk
const config = {
  store,
  router,
  firebaseConfig: { ...config }
  // ...other configs
};

Vue.use(sdk, config)
// routes
export const routes = [
  {
    path: '/',
    // no lazy loading (above-the-fold)
    component: require('../statics/Home').default,
    meta: { onLogin: '/dash' } // will be redirected to 'dash' when currentUser != null
  },
  {
    path: '/dash',
    children: require('../dash/routes').routes,
    component: () => import(/* webpackChunkName: 'dash' */ '../dash'),
    meta: { requiresAuth: true, onLogout: '/', signinUsingQueryToken: 'token', force: false } // needs currentUser != null; if currentUser == null, redirect to '/'; if has query token, signInUsingCustomToken using the token in query key 'token'. if force, signInUsingCustomToken even if already signed in
  },
  {
    path: '*',
    redirect: '/'
  }
];
// dash/index.vue
<template lang="pug">
  v-layout(column)
    //- navbar
    v-btn(@click="signout" color="red" dark) signout

    //- content
    v-content
      //- isLoggedIn and currentUserId will also be injected to every component
      h1.display-1 CurrentUser's id: {{ currentUserId }}
      
      //- footer
      v-footer
        span footer here
</template>

<script>
export default {
  mounted () {
    // isLoggedIn and currentUserId will also be injected to every component
    console.log('currentUserId:', this.currentUserId);
  },
  methods: {
    signout () {
      // the core sdk will be injected in this.$mc of all components
      this.$mc.auth().signout();
    }
  }
};
</script>

// statics/Home.vue
<template lang="pug">
  v-layout(row)
    v-btn(:loading="loading" @click="signin" color="primary") signin test
</template>

<script>
export default {
  data: () => ({ loading: false }),
  mounted () {
    this.sub = this.$mc.auth().currentUser$.subscribe(() => {
      this.loading = false;
    });
  },
  beforeDestroy () {
    if (this.sub) this.sub.unsubscribe();
  },
  methods: {
    signin () {
      this.loading = true;
      this.$mc.auth().signin('local', { email: 'test@mycure.md', password: 'password' });
    }
  }
};
</script>
4.15.1-alpha.29

6 years ago

4.15.1-alpha.28

6 years ago

4.15.1-alpha.27

6 years ago

4.15.1-alpha.26

6 years ago

4.15.1-alpha.25

6 years ago

4.15.1-alpha.24

6 years ago

4.15.1-alpha.23

6 years ago

4.15.1-alpha.22

6 years ago

4.15.1-alpha.21

6 years ago

4.15.1-alpha.20

6 years ago

4.15.1-alpha.19

6 years ago

4.15.1-alpha.18

6 years ago

4.15.1-alpha.17

6 years ago

4.15.1-alpha.16

6 years ago

4.15.1-alpha.15

6 years ago

4.15.1-alpha.14

6 years ago

4.15.1-alpha.13

6 years ago

4.15.1-alpha.11

6 years ago

4.15.1-alpha.9

6 years ago

4.15.1-alpha.7

6 years ago

4.15.1-alpha.5

6 years ago

4.15.1-alpha.4

6 years ago

4.15.1-alpha.3

6 years ago

4.15.1-alpha.0

6 years ago

4.15.0

6 years ago

4.14.1-alpha.7

6 years ago

4.14.1-alpha.4

6 years ago

4.14.1-alpha.3

6 years ago

4.14.1-alpha.2

6 years ago

4.14.1-alpha.1

6 years ago

4.14.1-alpha.0

6 years ago

4.14.1

6 years ago

4.1.0-alpha.4

6 years ago

4.1.0-alpha.3

6 years ago

4.1.0-alpha.2

6 years ago

4.1.0-alpha.1

6 years ago

4.1.0-alpha.0

6 years ago

4.0.1-alpha.1

6 years ago

4.0.1-alpha.0

6 years ago

0.2.0

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago