2.0.0 • Published 6 years ago

task-cancel v2.0.0

Weekly downloads
3
License
MIT
Repository
-
Last release
6 years ago

task-cancel

Cancellation mechanism, written in typescript.

Install

npm install task-cancel

Usage

suite.test("When cancelled, isCancelRequested is true.", test => {
	test.arrange();
	let source = new CancelTokenSource();
	source.cancel();

	test.assert();
	assert.equal(source.token.isCancelRequested, true);
});

suite.test("When cancelled, onCancel is triggered.", test => {
	test.arrange();
	let source = new CancelTokenSource();
	let isTriggered = false;
	source.token.onCancel.add(() => isTriggered = true);

	test.act();
	source.cancel();

	test.assert();
	assert.equal(isTriggered, true);
});

suite.test("When link cancelled, isCancelRequested is true.", test => {
	test.arrange();
	let parent = new CancelTokenSource();
	let source = new CancelTokenSource([parent.token]);

	test.act();
	parent.cancel();

	test.assert();
	assert.equal(source.token.isCancelRequested, true);
});
2.0.0

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.0

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago