open-index/open-npm huggingface dataset:
npm package: @karhoo/create-demand-bloc-module
Description: 🔥 Node.js CLI tool to generate Karhoo Demand Bussness Logic Component
Latest version: 20.1.2

<div align="center">
<a href="https://karhoo.com">
  <img
    alt="Karhoo logo"
    width="250px"
    src="https://cdn.karhoo.com/s/images/logos/karhoo_logo.png"
  />
</a>

<h1>Create Demand Bloc module</h1>

Node.js CLI tool to generate Karhoo Demand Bussness Logic Component.

<hr />

[![License](https://img.shields.io/badge/License-BSD%202--Clause-orange.svg)](https://opensource.org/licenses/BSD-2-Clause)

</div>

## Installation

```
npm i -g @karhoo/create-demand-bloc-module
```

## Usage

```js
cd packages
npx create-demand-bloc-module
```

## About BloC Pattern

1. [BLoC pattern explained](http://flutterdevs.com/blog/bloc-pattern-in-flutter-part-1/)

2. [BLoC with React Hooks](https://magarcia.io/2019/02/18/bloc-pattern-with-react-hooks)

3. [BLoC with Vue example](https://github.com/kevinrodriguez-io/vue-bloc-state-management)

## Contributing

### License

[BSD-2-Clause](../LICENSE)
npm package: @karhoo/demand-bloc-quotes
Description: BLoC to work with Karhoo Quotes API
Latest version: 20.1.2

<div align="center">
<a href="https://karhoo.com">
  <img
    alt="Karhoo logo"
    width="250px"
    src="https://cdn.karhoo.com/s/images/logos/karhoo_logo.png"
  />
</a>

<h1>demand-bloc-quotes</h1>

BLoC to work with Karhoo Quotes API
<br />

<hr />

[![License](https://img.shields.io/badge/License-BSD%202--Clause-orange.svg)](https://opensource.org/licenses/BSD-2-Clause)

</div>

## Installation

```sh
npm i @karhoo/demand-bloc-quotes
```

## Usage

```js

import { getApi } from '@karhoo/demand-api'
import { QuotesBloc } from '@karhoo/demand-bloc-quotes'

const api = getApi({
  url: 'api',
  defaultRequestOptionsGetter: () => ({
    headers: {
      identifier: 'XXXX',
      referrer: 'https://example-referer.com/'
    }
  })
})

/*
* The latitude in degrees. It must be in the range [-90.0, +90.0], with at least 4  decimal digits of precision.
* The longitude in degrees. It must be in the range [-180.0, +180.0], with at least 4  decimal digits of precision.
*/
const quotesSearchParams = {
  origin: {
    latitude: '51.501364',
    longitude: '-0.14189',
    displayAddress: 'Buckingham Palace, London SW1A 1AA',
  },
  destination: {
    latitude: '41.78650',
    longitude: '1.78954',
    displayAddress: 'Big Ben, Westminster, London SW1A 0AA, UK',
  },
  localTimeOfPickup: "2020-05-20T12:00"
}

/*
* quotesService use quotes V1 API which is depricated. Use quotesV2Service instead
*/
const quotesBloc = new QuotesBloc(api.quotesV2Service)

quotesBloc.filters = {
  numOfLuggage: 2,
  numOfPassengers: 2,
}

quotesBloc.matchingQuotes.subscribe((data) => {
  // quotes that accepts 2 passengers and 2 bags
  console.log('Matching quotes', data)
})

quotesBloc.otherAvailibleQuotes.subscribe((data) => {
  // all other quotes that did not match filters
  console.log('Other quotes', data)
})

quotesBloc.loading.subscribe(isLoading => {
  console.log('isLoading', isLoading)
})

quotesBloc.quotesExpired.subscribe(() => {
  console.log('Quotes Expired')

  quotesBloc.refreshQuotes() // requests quotes with same search params
})

quotesBloc.requestQuotes(quotesSearchParams)

```
npm package: @karhoo/demand-bloc-track-trip
Description: Bussness Logic Component (aka BLoC) for trip tracking functionality via Karhoo API
Latest version: 20.1.2

<div align="center">
<a href="https://karhoo.com">
  <img
    alt="Karhoo logo"
    width="250px"
    src="https://cdn.karhoo.com/s/images/logos/karhoo_logo.png"
  />
</a>

<h1>@karhoo/demand-bloc-track-trip</h1>

Bussness Logic Component (aka BLoC) for trip tracking functionality via Karhoo API
<br />

<hr />

[![License](https://img.shields.io/badge/License-BSD%202--Clause-orange.svg)](https://opensource.org/licenses/BSD-2-Clause)

</div>

## Installation

```sh
npm i @karhoo/demand-bloc-track-trip
```

## Usage

```js
import { getApi } from '@karhoo/demand-api'
import { TripBloc } from '@karhoo/demand-bloc-track-trip'

const api = getApi({
  url: 'api',
  defaultRequestOptionsGetter: () => ({
    headers: {
      identifier: 'XXXX',
      referrer: 'https://example-referer.com/',
    },
  }),
})

const tripBloc = new new TripBloc(api.tripService, api.fareService)()

tripBloc.trip.subscribe(data => {
  // get trip info
  console.log('trip', data)
})

tripBloc.error.subscribe(data => {
  // get trip fetching error
  console.log('Error fetch trip', data)
})

tripBloc.finalFare.subscribe(data => {
  // get final fare info
  console.log('Final Fare', data)
})

tripBloc.pickUpTimeUpdates.subscribe(data => {
  // get pickup time updates
  console.log('New PickupTime', data)
})

//track trip updates
tripBloc.track(tripId)

// stop polling track and fare
tripBloc.cancelPolling()

// cancel trip by follow code
tripBloc.cancellByFollowCode(code, cancellationParams)
```
npm package: @karhoo/demand-bloc-trip-create
Description: BLoC to work with Karhoo Autocomplete and Place APIs
Latest version: 20.1.2

<div align="center">
<a href="https://karhoo.com">
  <img
    alt="Karhoo logo"
    width="250px"
    src="https://cdn.karhoo.com/s/images/logos/karhoo_logo.png"
  />
</a>

<h1>demand-bloc-trip-create</h1>

BLoC to work with Karhoo Autocomplete and Place APIs
<br />

<hr />

[![License](https://img.shields.io/badge/License-BSD%202--Clause-orange.svg)](https://opensource.org/licenses/BSD-2-Clause)

</div>

## Installation

```sh
npm i @karhoo/demand-bloc-trip-create
```