1.0.18 • Published 1 year ago

miwon v1.0.18

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Miwon

Miwon is oriented to intergrated state container with api fetching and cache normalizing.

Concept

Notice

  • Miwon is a kind of seasoning for cook.
  • This library is experimental and unstable. (also, document is unkind)

Installation

npm install miwon

yarn add miwon

Quick Start

1. Add Miwon to your project

import { addMiwon } from 'miwon'

const miwon = addMiwon({
  config: {
    baseURL: 'https://my-json-server.typicode.com' //change base url for your project
  }
})

2. Build Normalizer.

import { schema, normalize } from 'miwon'

const postsNormalizer = (res: any) => {
  const commentEntity = new schema.Entity('comments')

  const postEntity = new schema.Entity('posts', {
    comments: [commentEntity]
  })

  const posts = new schema.Array(postEntity)
  return normalize(res, posts).entities
}

3. Get data with Normalizer.

miwon.miwonQuery('/2hakjoon/miwon/posts', postsNormalizer).then(
  () => console.log(getState()) // you can see normalized result which cached
)

Todo

  • store
    • createStore
  • subscription
    • subscribe
    • unsubscribe
    • clear
    • getSubscriptions
  • fetcher
    • createFetcher
    • errorHandling
  • cahce
    • cache with normalized data
    • get cache with key
  • normalizer
1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.9

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago