https://github.com/smart-table/smart-table-server
allows to move core logic of your smart table to your server.
https://github.com/smart-table/smart-table-server
Last synced: 9 months ago
JSON representation
allows to move core logic of your smart table to your server.
- Host: GitHub
- URL: https://github.com/smart-table/smart-table-server
- Owner: smart-table
- License: mit
- Created: 2017-05-22T20:07:27.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2022-03-23T23:00:45.000Z (about 4 years ago)
- Last Synced: 2025-09-01T10:09:23.328Z (10 months ago)
- Language: JavaScript
- Size: 125 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# smart-table-server
[](https://circleci.com/gh/smart-table/smart-table-server)
[smart-table](https://smart-table.github.io/www/dist/) 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](https://smart-table.github.io/www/dist/) for more example.
The function takes as argument the current table state.
### example
```Javascript
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
```