# immutable-core-service

> Services built on Immutable Core

Latest version **0.3.0** (published 2023-12-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install immutable-core-service
pnpm add immutable-core-service
yarn add immutable-core-service
bun add immutable-core-service
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2023-12-16 |
| First published | 2017-08-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 17.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Ersun Warncke |
| Maintainers | ersun.warncke |

## Links

- npm: https://www.npmjs.com/package/immutable-core-service
- Repository: https://github.com/warncke/immutable-core-service
- Homepage: https://github.com/warncke/immutable-core-service#readme
- Issues: https://github.com/warncke/immutable-core-service/issues
- npm.io page: https://npm.io/package/immutable-core-service

## Dependencies (4)

- [bluebird](https://npm.io/package/bluebird.md) 3.5.3
- [stable-id](https://npm.io/package/stable-id.md) 1.0.13
- [if-defined](https://npm.io/package/if-defined.md) 1.0.18
- [immutable-core](https://npm.io/package/immutable-core.md) 3.1.0

## Recent versions

- 0.3.0 (latest) — 2023-12-16
- 0.2.41 — 2018-11-18
- 0.2.40 — 2018-11-17
- 0.2.39 — 2018-01-15
- 0.2.38 — 2018-01-15
- 0.2.37 — 2018-01-15
- 0.2.36 — 2017-12-20
- 0.2.35 — 2017-12-20
- 0.2.34 — 2017-12-18
- 0.2.33 — 2017-12-18
- 0.2.32 — 2017-12-18
- 0.2.31 — 2017-12-02
- 0.2.30 — 2017-12-01
- 0.2.29 — 2017-12-01
- 0.2.28 — 2017-11-20
- … 33 more at https://npm.io/package/immutable-core-service/versions

## README

# immutable-core-service

Immutable Core Service integrates with the
[Immutable App](https://www.npmjs.com/package/immutable-app) ecosystem to
provide persistent global services backed by shared immutable data state that
can be reinitialized on a periodic basis.

Immutable Core Service is designed to support use cases like app configuration
and access control that use data from
[Immutable Core Models](https://www.npmjs.com/package/immutable-core-model)
but that data does not change from one request to the next.

Immutable Core Service requires native async/await support.

## Creating a new service

    var fooService = new ImmutableCoreService({
        name: 'foo',
        methods: {
            foo: function (args) { ... },
        },
        initialize: function (args) { .. },
        reinitializeInterval: 10,
    })

In this example a service named `foo` is defined with a single `foo` method.

This will create an
[Immutable Core](https://www.npmjs.com/package/immutable-core) module with the
module name `fooService` and two methods: `foo` and `initialize`.

The `initialize` method is called once when the service is first created and is
then called at an interval defined by `reinitializeInterval` which is in
seconds.

The data object returned by `initialize` will become the shared state for the
service.

Data is stored in the module data and can be accessed via
`fooService.module.data`.

## Initializing services

    await ImmutableCoreService.initializeAll()

The `initializeAll` method will call the `initialize` method for each globally
registered service and resolve once all services have been initialized.

After all services have been initialized the global reinitialize check will be
started.

## Starting reinitialize check

    ImmutableCoreService.reinitializeStart()

`reinitializeStart` sets an interval that will call `reinitializeCheck` every
1 second (1000ms).

This is called by `initializeAll` once it completes.

## Stopping reinitialize check

    ImmutableCoreService.reinitializeStop()

`reinitializeStop` clears the interval set by `reinitializeStart`. It does not
abort any initialize calls in progress.

---
_Source: https://npm.io/package/immutable-core-service · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
