🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

react-vodka

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-vodka

React CRUD system

0.0.2
Source
npm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

Vodka

need to create an object of objects properties which can be mapped into children So I need a map of

parent: {
    child:{
        child:{
            child:{}
        },
    },
};

Calling {parent}_{child}/UPDATE_OBJECTS updates parent's child property in reducer

Base object needs to consist of

{
    objects: {}, //array of objects indexed by key
    //singular object requires a loading boolean similar to below for multiple loading states
    loading: false, //boolean for overall loading state of module
    pagination: {
        total: null,
        currentPage: 0,
        perPage: null,
    },//pagination data from laravel for paginating objects from server calls
    paginationKeys: [], //list of keys to paginate in the current context: populated from filter handler
    currentPage: 0,
    filter: (object) => {return true;},//function to filter the pagination
    [{child_module_name*}] => {},
}

Example usage

import Vodka from 'react-vodka';

const vodka = new Vodka({
    baseUrl: 'https://api.bookstore.local',
    headers: {
        'Content-Type': 'application/json',
    },
});

vodka.shot({
    name: 'books',
    endpoint: 'books/{book}',
    key:'slug',
});

/**
* Create a mapped child module of books 
*/
vodka.shot({
    parents: 'books',
    name: 'pages',
    endpoint: 'books/{book}/{pages}/',
});

/**
* Create a mapped child module of pages 
*/
vodka.shot({
    parents: 'books.pages',
    name: 'words',
    endpoint: 'books/{book}/pages/{page}/words/{word}',
});

export default vodka;


//additional example 

vodka.shot({
    name: 'pages',
    endpoint: '/books/{book}/pages/{pages}/',
    parents: 'books',//optional
    key: 'slug',//optional default "id"
    configs: [//optional [prefixed automatically]
        'CREATE_LINE',
        'CREATE_LINE_ASYNC',
    ],//optional
    reducers: {//optional
        'CREATE_LINE' : (state, action) => {
            return Object.assign({}, state, {
                lines: Object.assign(state.books[action.params.book].lines, action.lines),
            });
        },
    },
    sagas: {//optional
        'CREATE_LINE_ASNYC': function* () {
            while(true) {
                const action = yield effects.take('blah');
            }
        },
    },
    except: [//optional
        'store',//remove store method
    ],
});


//Muiltple shots example 


vodka.shots([
    {
        name: 'books',
        endpoint: 'books/{book}',
        key:'slug',
    },
    {
        name: 'pages',
        parents: 'books',
        endpoint: 'books/{book}/{pages}/',
    },
    {
        name: 'words',
        parents: 'books.pages',
        endpoint: 'books/{book}/pages/{page}/words/{word}',
    },
]);

export default vodka;

Reducer file

import {combineReducers} from 'redux';
import {routerReducer} from 'react-router-redux';

import vodka from './mixers';

export default combineReducers({
    routing: routerReducer,
    ...vodka.getReducers(),
});

Saga file

import vodka from './mixers';

const sagas = [
    ...vodka.getSagas(),
];

export default sagas;

Routes file

import React, {Component} from 'react';
import {connect} from 'react-redux';
import {
    Route,
    Switch,
    withRouter,
} from 'react-router-dom';


import vodka from './mixers';

class Routes extends Component {

    render() {
        return (
            <Switch>
                <Route exact path="/" component={Login}/>
                <Route exact path="/register/" component={Register}/>
                <vodka.getRoutes/>
            </Switch>
        );
    }
}

export default withRouter(connect()(Routes));

Must import vodka mixers before reducers and sagas are setup

TODO

  • Need to find a way to add a trailing slash if outgoing url doesn't already have one
  • [DONE] Need to figure out how to have a manageable config object
  • [DONE] Need to replace child's parent's reducer function with an object with child's key as a property
  • Need to add sagas to manage children easier rather than update parent each time
  • Figure out how to export a immutable object/array
  • [DONE] Rename Vodka file to index
  • Build package and install in stylique app for testing properly
  • Have a go at building a routes component
  • [DONE] Refactor child to parent method calling by removing parent, name object
  • Make sure child reducer types do not conflict with parent's
  • Test that sagas work correctly
  • Test child setup
  • Update dependencies
  • Rewrite README

Not so important right now

  • Add custom reducer methods to vodka function config
  • Add custom saga methods to vodka function config

Keywords

react

FAQs

Package last updated on 30 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts