storyshare

3.22.5 • Public • Published

StoryShare API Handler

Initialize the API:

import Site from 'storyshare';

let s = new Site();
s.start()
.then(launchApp());

Dispatch a request using a tracking key:

componentWillMount() {
  s.req('posts').track('newsfeed').read();
}

or with a promise once complete, to run further actions:

componentWillMount() {
  s.req('posts').track('newsfeed').promise().read()
  .then(posts => console.log('got some posts', posts));
}

Get the completion state, and the response content:

const mapStateToProps = (state) => ({
  feedReady: s.getComplete('newsfeed'),
  newsFeed: s.getResponse('newsfeed')
});

render() {
  return this.props.feedReady ?
    props.newsFeed.map(({ title, content }) => <div><h1>{ title }</h1><p>{ content }</p></div>)
    <Spinner />;
}

Readme

Keywords

Package Sidebar

Install

npm i storyshare

Weekly Downloads

6

Version

3.22.5

License

UNLICENSED

Unpacked Size

1.6 MB

Total Files

160

Last publish

Collaborators

  • npmchrisl
  • simpleigh