npm.io
0.1.0 • Published 5 years ago

@wiredcraft/miniprogram-sparrow

Licence
MIT
Version
0.1.0
Deps
0
Size
13 kB
Vulns
0
Weekly
0
Stars
1

Install

yarn add @wiredcraft/miniprogram-sparrow

Usage

// store/name.js

import { atom } from "sparrow";

export const firstName = atom("Jack");

// the action
export function updateFirstName(name) {
  write(firstName, name);
}
// components/hello.js
import { write, behavior as sparrow } from "sparrow";
import { firstName, updateFirstName } from "./store/name";

Component({
  atoms: { firstName },

  behaviors: [sparrow],
  lifetimes: {
    attached() {
      console.log(this.firstName);
    },
  },
  methods: {
    handleButtonOnTap() {
      updateFirstName("Rose");
    },
  },
});