GithubHelp home page GithubHelp logo

Comments (4)

u3u avatar u3u commented on June 14, 2024

Hi, you can refer to this example:

Edit Vue Hooks Examples

<script>
import { createComponent } from 'vue-function-api';
import { useState, useGetters, useMutations, useActions } from '@u3u/vue-hooks';

export default createComponent({
  name: 'App',

  setup() {
    const state = {
      ...useState(['count']),
    };

    const getters = {
      ...useGetters(['plusOne']),
    };

    const mutations = {
      ...useMutations(['increment', 'decrement']),
    };

    const actions = {
      ...useActions(['incrementAsync', 'decrementAsync']),
    };

    return {
      ...state,
      ...getters,

      state,
      getters,
      mutations,
      actions,
    };
  },

  render() {
    const { count, plusOne, state, getters, mutations, actions } = this;
    console.log(count); // number
    console.log(plusOne); // number
    console.log(state.count); // ComputedWrapper
    console.log(getters.plusOne); // ComputedWrapper

    return (
      <div id="app">
        <div>count(state): {count}</div>
        <div>plusOne(getters): {plusOne}</div>
        <button onClick={() => mutations.increment()}>increment</button>
        <button onClick={() => mutations.decrement()}>decrement</button>
        <button onClick={() => actions.incrementAsync()}>incrementAsync</button>
        <button onClick={() => actions.decrementAsync()}>decrementAsync</button>
      </div>
    );
  },
});
</script>

from vue-hooks.

ChrisMichaelPerezSantiago avatar ChrisMichaelPerezSantiago commented on June 14, 2024

Regard @u3u ,

I recommend if you can, add that type of structure (example) as documentation for official use.

from vue-hooks.

u3u avatar u3u commented on June 14, 2024

Yes, I am writing documentation and examples.
I usually work very busy, only available on weekends. 😅

from vue-hooks.

u3u avatar u3u commented on June 14, 2024

Welcome to visit: https://vue-hooks.netlify.com

from vue-hooks.

Related Issues (20)

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.