Skip to content

Commit

Permalink
Merge branch 'release/release/0.15.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
holtwick committed Nov 30, 2023
2 parents 2bea73e + 611ad64 commit 072bef8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "zeed",
"type": "module",
"version": "0.15.4",
"version": "0.15.5",
"description": "🌱 Simple foundation library",
"author": {
"name": "Dirk Holtwick",
Expand Down
9 changes: 5 additions & 4 deletions src/common/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ interface ZeedGlobalIntegration {
_zeedGlobal?: ZeedGlobalContext
}

/** Identify the right global for the environment. Might be obsolete these days, due to globalThis. */
function _global(): ZeedGlobalIntegration {
if (typeof self !== 'undefined')
return self as ZeedGlobalIntegration
Expand All @@ -22,10 +23,10 @@ function _global(): ZeedGlobalIntegration {
throw new Error('unable to locate global object')
}

export function getGlobalContext(): ZeedGlobalContext {
/** Global object to work across module boundaries as well. Internally already used for logger and emitter. */
export function getGlobalContext<T = ZeedGlobalContext>(defaultValue = {}): T {
const gcontext = _global()
if (gcontext._zeedGlobal == null)
gcontext._zeedGlobal = {}

return gcontext._zeedGlobal
gcontext._zeedGlobal = defaultValue
return gcontext._zeedGlobal as T
}
2 changes: 1 addition & 1 deletion src/common/msg/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ declare global {
}

/** Global emitter that will listen even across modules */
export function getGlobalEmitter(): Emitter<ZeedGlobalEmitter> {
export function getGlobalEmitter<T extends ListenerSignature<T> = ZeedGlobalEmitter>(): Emitter<T> {
let emitter = getGlobalContext().emitter
if (!emitter) {
emitter = new Emitter()
Expand Down

0 comments on commit 072bef8

Please sign in to comment.