allows to move core logic of your smart table to your server.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
dist first commit May 24, 2017
example first commit May 24, 2017
test first commit May 24, 2017
.gitignore Initial commit May 22, 2017
.npmignore first commit May 24, 2017
LICENSE Initial commit May 22, 2017
README.md first commit May 24, 2017
circle.yml first commit May 24, 2017
index.js first commit May 24, 2017
package.json v0.1.1 May 24, 2017
rollup.config.js first commit May 24, 2017
yarn.lock first commit May 24, 2017

README.md

smart-table-server

CircleCI

smart-table extension which allows you to move your business logic from the client to the server without (barely) changing your client code. Ideal when your data is fetched through an http api using AJAX.

see demo

Installation

yarn

yarn add smart-table-server

npm

npm install --save smart-table-server

Usage

The module is a factory which takes as argument an object with a query function.

The query function (likely your server sdk) must returns a promise which will eventually resolve with an object with the following properties

  • data: an array containing your data
  • summary: an object containing the summary information (see smart-table documentation for more example.

The function takes as argument the current table state.

example

import {table} from 'smart-table-core';
import ext from 'smart-table-server';

const st = table({data:[]}, ext({
    query:(tableState)=>{
        // transform the table state into an http query, example:
        const query = yourSdk.queryfy(tableState);

        //send the request (return a promise), example:
        return yourSdk.get(query)
            .then(result =>{
                //parse the response and return the required object, example:
                return yourSdk.parse(result);
            });
    }
}));


//then regular smart-table usage
st.sort({pointer:'foo'});
// > send http request and update the system with the response