1.4.5 • Published 1 month ago

badmfck-signal v1.4.5

Weekly downloads
-
License
MIT
Repository
-
Last release
1 month ago

#An implementation of a signaling mechanism used to connect components and transfer data between them

How to use: Create an instance of Signal with prefered data type: const S_TEST:Signal=new Signal()

Subscribe to signal, obtain callback id. const callbackID = S_TEST.subscribe(str=>{console.log(str)})

Call invokation procedure S_TEST.invoke("test")

Remove subscribtion, using id: S_TEST.remove("test1")

Remove all subscribtions from signal: S_TEST.clear();

shortcuts:

Subscribe to signalling pipe with name stored in group. group is optional, if not exists, global pipeline will use s_subscribe(group)

s_unsubscribe(id) unsubscribe from signal

The main principle is using one point in project to store all major interactions between sources without connectig them directly, also called as GlobalDispatcher or Spine.

example: file: GlobalDispatcher.ts export class GD{ static S_SAVE_DATA:Signal=new Signal(); }

file: DataManager.ts export GD from './GD' export class DataManager{ constructor(){ GD.S_SAVE_DATA.subscribe(data=>{ console.log(${data} saved!) }) } }

file: ViewController.ts export GD from './GD' button.onClick=()=>{ GD.S_SAVE_DATA.invoke("Test!") }

1.4.5

1 month ago

1.4.4

5 months ago

1.4.3

5 months ago

1.4.2

5 months ago

1.4.1

6 months ago

1.3.9

6 months ago

1.3.8

7 months ago

1.3.7

7 months ago

1.3.6

7 months ago

1.3.5

7 months ago

1.3.4

7 months ago

1.3.3

7 months ago

1.3.2

7 months ago

1.3.1

7 months ago

1.2.9

7 months ago

1.2.8

7 months ago

1.2.7

7 months ago

1.2.6

8 months ago

1.2.5

8 months ago

1.2.4

8 months ago

1.2.3

8 months ago

1.2.2

8 months ago

1.2.1

8 months ago

1.1.9

8 months ago

1.1.6

8 months ago

1.1.5

8 months ago

1.1.4

8 months ago

1.1.3

8 months ago

1.1.2

8 months ago

1.1.1

8 months ago

1.0.8

8 months ago

1.0.7

8 months ago

1.0.5

8 months ago

1.0.4

8 months ago

1.0.3

8 months ago

1.0.1

9 months ago

1.0.0

9 months ago