# @schema-plugin-flow/sifo-singleton

> sifo singleton

Latest version **1.2.0** (published 2022-05-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install @schema-plugin-flow/sifo-singleton
pnpm add @schema-plugin-flow/sifo-singleton
yarn add @schema-plugin-flow/sifo-singleton
bun add @schema-plugin-flow/sifo-singleton
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2022-05-31 |
| First published | 2020-08-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 11 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 425 |
| Author | FrominXu |
| Maintainers | fromin |
| Keywords | schema-plugin-flow, sifo, singleton |

## Links

- npm: https://www.npmjs.com/package/@schema-plugin-flow/sifo-singleton
- Repository: https://github.com/alibaba/schema-plugin-flow
- Homepage: https://github.com/alibaba/schema-plugin-flow#readme
- Issues: https://github.com/alibaba/schema-plugin-flow/issues
- npm.io page: https://npm.io/package/@schema-plugin-flow/sifo-singleton

## Dependencies (1)

- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.12.5

## Alternatives

- [@regle/core](https://npm.io/package/@regle/core.md) — 47.0K weekly downloads
- [typeof-arguments](https://npm.io/package/typeof-arguments.md) — 12.5K weekly downloads
- [@lokalise/projects-engine-contracts](https://npm.io/package/@lokalise/projects-engine-contracts.md) — 978 weekly downloads
- [@osjwnpm/nam-laboriosam-quibusdam](https://npm.io/package/@osjwnpm/nam-laboriosam-quibusdam.md) — 70 weekly downloads
- [@oridune/validator](https://npm.io/package/@oridune/validator.md) — 16 weekly downloads

## Recent versions

- 1.2.0 (latest) — 2022-05-31
- 1.1.4 — 2021-07-31
- 1.1.3 — 2021-07-21
- 1.1.2 — 2021-04-26
- 1.1.1 — 2021-03-09
- 1.1.0 — 2020-11-17
- 1.0.4 — 2020-11-05
- 1.0.3 — 2020-09-15
- 1.0.2 — 2020-09-15
- 1.0.1 — 2020-09-10
- 1.0.0 — 2020-08-30

## README

# sifo-singleton

 这是一个全局单例容器，用于注册插件与组件，以命名空间区分。

## SifoSingleton 类

*SifoSingleton实例化参数*

参数          | 说明        | 类型 | 是否必传 | 默认值
-------------|-------------|-----|-----|-----
namespace    | 命名空间，插件与组件通过同一命名空间读取 | string | 是 | - |


## 方法

| 方法名                 | 参数/类型            | 返回值类型             | 描述         |
| --------------------- | -------------------| --------------------- | ---------------------------------------------------------------------------------------------------|
| registerItem          | (id: string, item: function)  | -          | 注册对象      |
| getRegisteredItems    | ()                   | array               | 获取所有的命名空间下的注册对象   |

> 代码示例-注册
```javascript
import SifoSingleton from '@schema-plugin-flow/sifo-singleton';
const singleton = new SifoSingleton('test');
singleton.registerItem('extendId01', (params) => {
  return {
    version: '1.0.0',
    plugins: [
      {
        componentPlugin: singleton_comp_plg,
        pagePlugin: {}
      }, 
      {
        pagePlugin: {
          onPageInitial: params => {
            console.log('singleton1 page plugin')
          }
        }
      }
    ],
    components: {
      test: TestComp
    }
  }
});
```

> 代码示例-取出
```javascript
import SifoSingleton from '@schema-plugin-flow/sifo-singleton';
const singleton = new SifoSingleton('test');
const singletonItems = singleton.getRegisteredItems({ param1: 'testssss' });
singletonItems.forEach(registerItem => {
    const { components = {}, plugins = [] } = registerItem;
});
```

---
_Source: https://npm.io/package/@schema-plugin-flow/sifo-singleton · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
