Install the module using NPM or Yarn:
yarn add @justeat/f-services
npm install @justeat/f-services
You can import it in your component/application like this (please note that styles have to be imported separately)
import { windowServices } from '@justeat/f-services';
// You can then (optionally) destructure
const { addEvent, getWindowWidth, removeEvent } = windowServices;
If you are using Webpack, you can import the component dynamically to separate the services bundle from the main bundle.client.js
:
Create an axios client.
Create an axios client with all response JSON transformed to camelCase.
Uses the navigator API (falling back to moz/webkit) to return network information.
Recursively converts object's property names to camelCase.
Returns the locale for the current tenant, if the configuration for that locale is present, otherwise returns the default locale.
Returns the theme based on the user's locale. Either ml
for Menulog or je
for Just Eat.
Uses the window-or-global
module for SSR compatibility.
Add an event listener with a callback function. Optional throttling. Returns the function that will be called by the listener.
Returns the current innerHeight.
Returns the current innerWidth.
Remove an event listener. To remove a throttled event, pass in the value returned by addEvent
when the listener was added.
Returns a deep object by traversing following the provided path.
Returns an object containing arrays of the names of valid and invalid validation rules.
Returns a boolean indicating whether the provided postcode is valid in the provided locale.
Returns a boolean indicating whether the provided phone number is valid in the provided locale.x