@vyke/context
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

@vyke/context

A simple context manager for running code in a specific context

Installation

npm i @vyke/context

API

defineContext

Defines a context that can be used to run code in a specific context

const context = defineContext('test')

const context1 = 'test 1'
const context2 = 'test 2'
const context3 = 'test 3'

context.run(context1, () => {
	console.log(context.getValue(context1)) // test 1

	context.run(context2, () => {
		console.log(context.getValue(context2)) // test 2

		context.run(context3, () => {
			console.log(context.getValue(context3)) // test 3
		})

		console.log(context.getValue(context2)) // test 2
	})

	console.log(context.getValue(context1)) // test 1
})

Others vyke projects

Package Sidebar

Install

npm i @vyke/context

Weekly Downloads

1

Version

0.0.2

License

MIT

Unpacked Size

6.12 kB

Total Files

7

Last publish

Collaborators

  • albizures