@farfetch/blackout-core

1.102.0 • Public • Published

@farfetch/blackout-core

Clients to connect to the Farfetch Platform Solutions' services and modules to manage the application data layer and global state.

Installation

yarn

yarn add @farfetch/blackout-core

npm

npm i @farfetch/blackout-core

Usage

Update your store to include the reducers and entities, like the example below:

// Typically in `store/buildStore.js`
import { applyMiddleware, combineReducers, createStore } from 'redux';
import { bagMiddleware } from '@farfetch/blackout-core/analytics/redux/middlewares';
import { entitiesMapperReducer } from '@farfetch/blackout-core/entities/redux';
import checkout from '@farfetch/blackout-core/checkout/redux';
import listing from '@farfetch/blackout-core/products/listing/redux';
import otherScopeReducer from './other-scope';

// Create your reducer based on a combination of other reducers and entities
const reducers = combineReducers({
  checkout,
  entities: entitiesMapperReducer(),
  listing,
  otherScope: otherScopeReducer,
});
const middlewares = [bagMiddleware()];
const store = createStore(reducers, applyMiddleware(...middlewares));

With the store configured, you just need to import and use what you need

// Fetching a listing page
import { doGetListing } from '@farfetch/blackout-core/products/listing/redux';
import { getListing as getListingClient } from '@farfetch/blackout-core/products/listing/client';

const fetchListing = doGetListing(getListingClient);

fetchListing(args);

Additional configuration

Since this package is published in its original structure, all the source code is contained in a src folder. This means you might need additional configurations:

  • In order to have friendly imports (@farfetch/blackout-core vs @farfetch/blackout-core/src), you probably want to add aliases

    // Webpack example
    config.resolve.alias = {
      '@farfetch/blackout-core': '@farfetch/blackout-core/src',
    };
  • In order to have your project running, you probably need a specific loader

    // Webpack example
    config.module.rules.push({
      test: /\.jsx?$/,
      include: [/node_modules\/@farfetch\/blackout-core/],
      use: [
        {
          loader: 'babel-loader',
          options: myBabelConfig,
        },
      ],
    });

Contributing

Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.

Please read the CONTRIBUTING file to know what we expect from your contribution and the guidelines you should follow.

License

MIT @ Farfetch

Readme

Keywords

none

Package Sidebar

Install

npm i @farfetch/blackout-core

Weekly Downloads

45

Version

1.102.0

License

MIT

Unpacked Size

4.58 MB

Total Files

2385

Last publish

Collaborators

  • farfetch-oss