1.2.2 • Published 6 years ago

attamodel v1.2.2

Weekly downloads
2
License
Apache-2.0
Repository
github
Last release
6 years ago

Attamodel

An ORM-like class for managing your Redux State in a simple immutable way

NPM JavaScript Style Guide

Install

npm install --save attamodel

API Docs Site

Usage

import {AttaModel} from 'attamodel'

// action = {
//     data: [
//         {id: '12345', name: 'My Blog Post 1'},
//         {id: '56789', name: 'My Blog Post 2'},
//         {id: '101112', name: 'My Blog Post 3'}
//     ],
//     meta: {
//         page: 1,
//         page_size: 50,
//         total_pages: 1,
//         total_results: 3
//     },
//     params: {}
// }

// someReducer.js
// state = {}
case GET_POSTS_SUCCESS:
    const data = new AttaModel(state, 'posts')
    return {
        ...data
            .bulkInsert(action.data)
            .addParams(action.params),
            .addMeta(action.meta)
            .getNextState(),
        error: false
    }

// nextState = {
//     posts: {
//         '12345': {id: '12345', name: 'My Blog Post 1'},
//         '56789': {id: '56789', name: 'My Blog Post 2'},
//         '101112': {id: '101112', name: 'My Blog Post 3'}
//     },
//     ids: {
//         '12345': '12345',
//         '56789': '56789',
//         '101112': '101112'
//     },
//     meta: {
//         page: 1,
//         page_size: 50,
//         total_pages: 1,
//         total_results: 3
//     },
//     params: {
//     }
// }

License

Apache-2.0 © Attainia

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago