A flux implementation of the Shopify API.
npm install --save shopify-api-flux
This project uses ES6 (via Babel et al.). So the examples are in ES6. However, since the distribution (and main file in package.json) is actually compiled down to ES5, you should be able to use this in your ES5 projects without issue.
Please let me know (or open a PR) if this is not the case.
Currently, there is only one example but I intend to add more over time. For now there is a react native app in the examples/native directory that demonstrates creating and storing a session as well as fetching orders, products and shop details.
This will get fleshed out more as the API comes closer to complete.
import ShopifyAPI from "shopify-api-flux";
const { Session, Shop } = ShopifyAPI;
// set the Domain and API token
Session.init("YOUR_SHOP", "YOUR_API_TOKEN")
class ShopView extends React.Component {
constructor(props) {
super(props);
this.state = { shop: null }
}
render() {
return (
// YOUR VIEW CODE
);
}
componentWillMount() {
Shop.store.addListener(this._onChange.bind(this));
}
componentDidMount() {
Shop.fetch()
}
_onChange() {
this.setState({ shop: Shop.store.getCurrent() });
}
}