disposables

WebJar for disposables

Лицензия

Лицензия

Apache-2.0
Группа

Группа

org.webjars.npm
Идентификатор

Идентификатор

disposables
Последняя версия

Последняя версия

1.0.2
Дата

Дата

Тип

Тип

jar
Описание

Описание

disposables
WebJar for disposables
Ссылка на сайт

Ссылка на сайт

https://www.webjars.org
Система контроля версий

Система контроля версий

https://github.com/gaearon/disposables

Скачать disposables

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.webjars.npm/disposables/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>disposables</artifactId>
    <version>1.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/disposables/
implementation 'org.webjars.npm:disposables:1.0.2'
// https://jarcasting.com/artifacts/org.webjars.npm/disposables/
implementation ("org.webjars.npm:disposables:1.0.2")
'org.webjars.npm:disposables:jar:1.0.2'
<dependency org="org.webjars.npm" name="disposables" rev="1.0.2">
  <artifact name="disposables" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='disposables', version='1.0.2')
)
libraryDependencies += "org.webjars.npm" % "disposables" % "1.0.2"
[org.webjars.npm/disposables "1.0.2"]

Зависимости

Библиотека не имеет зависимостей. Это самодостаточное приложение, которое не зависит ни от каких других библиотек.

Модули Проекта

Данный проект не имеет модулей.

NOT ACTIVELY MAINTAINED

This project works fine but is not actively maintained.
For the new code, you might want to try the new official rx.disposables package instead.

disposables npm package

Disposables let you safely compose resource disposal semantics.
Think DOM nodes, event handlers, socket connections.

This implementation of disposables is extracted from RxJS.
I took the liberty to tweak the code style to my liking and provide this as a standalone package.

This tiny package includes several disposables:

The API is mostly the same as RxJS except stricter in a few places.
It does not strive for 100% API compatibility with RxJS, but generally behavior is the same.

It's best if you consult the source and tests, as classes are small and few.

Usage

import { Disposable, CompositeDisposable, SerialDisposable } from 'disposables';

// or you can import just the ones you need to keep it even tinier
// import SerialDisposable from 'disposables/modules/SerialDisposable';

function attachHandlers(node) {
	let someHandler = ...;
	node.addEventHandler(someHandler);

	// use Disposable to guarantee single execution
	return new Disposable(() => {
	  node.removeEventHandler(someHandler);
	});
}

// CompositeDisposable lets you compose several disposables...
let nodes = ...;
let compositeDisp = new CompositeDisposable(nodes.map(attachHandlers));

// and more later...
let moreNodes = ...
moreNodes.map(attachHandlers).forEach(d => compositeDisp.add(d));

// and dispose them at once!
function goodbye() {
	compositeDisp.dispose();
}

// ... or replace with a bunch of new ones ...
let serialDisp = new SerialDisposable();
serialDisp.setDisposable(compositeDisp);

function replaceNodes(newNodes) {
	let nextCompositeDisp = new CompositeDisposable(newNodes.map(attachHandlers));

	// release all the previous disposables:
	serialDisp.setDisposable(nextCompositeDisp);
}

// with a guarantee of each dispose() called only once.

License

Like the original RxJS code, it is licensed under Apache 2.0.

Версии библиотеки

Версия
1.0.2
1.0.1