-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from pilsy/fix/decorators-use-reflect
fix(decorators): Use reflect metadata
- Loading branch information
Showing
8 changed files
with
100 additions
and
71 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import 'reflect-metadata'; // Ensure reflect-metadata is imported | ||
import { GETTER_METADATA_KEY } from '../workflows/Workflow'; | ||
|
||
export const Get = (name?: string) => { | ||
return (target: any, propertyKey: string) => { | ||
if (!target.constructor._getters) { | ||
target.constructor._getters = {}; | ||
} | ||
target.constructor._getters[name || propertyKey] = propertyKey; | ||
const getters = Reflect.getMetadata(GETTER_METADATA_KEY, target) || {}; | ||
getters[name || propertyKey] = propertyKey; | ||
Reflect.defineMetadata(GETTER_METADATA_KEY, getters, target); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import 'reflect-metadata'; | ||
import { QUERY_METADATA_KEY } from '../workflows/Workflow'; | ||
|
||
export const Query = (name?: string) => { | ||
return (target: any, propertyKey: string) => { | ||
if (!target.constructor._queries) { | ||
target.constructor._queries = []; | ||
} | ||
target.constructor._queries.push([name || propertyKey, propertyKey]); | ||
const queries = Reflect.getMetadata(QUERY_METADATA_KEY, target) || []; | ||
queries.push([name || propertyKey, propertyKey]); | ||
Reflect.defineMetadata(QUERY_METADATA_KEY, queries, target); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import 'reflect-metadata'; // Ensure reflect-metadata is imported | ||
import { SETTER_METADATA_KEY } from '../workflows/Workflow'; | ||
|
||
export const Set = (name?: string) => { | ||
return (target: any, propertyKey: string) => { | ||
if (!target.constructor._setters) { | ||
target.constructor._setters = {}; | ||
} | ||
target.constructor._setters[name || propertyKey] = propertyKey; | ||
const setters = Reflect.getMetadata(SETTER_METADATA_KEY, target) || {}; | ||
setters[name || propertyKey] = propertyKey; | ||
Reflect.defineMetadata(SETTER_METADATA_KEY, setters, target); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import 'reflect-metadata'; | ||
import { SIGNAL_METADATA_KEY } from '../workflows/Workflow'; | ||
|
||
export const Signal = (name?: string) => { | ||
return (target: any, propertyKey: string) => { | ||
if (!target.constructor._signals) { | ||
target.constructor._signals = []; | ||
} | ||
target.constructor._signals.push([name || propertyKey, propertyKey]); | ||
const signals = Reflect.getMetadata(SIGNAL_METADATA_KEY, target) || []; | ||
signals.push([name || propertyKey, propertyKey]); | ||
Reflect.defineMetadata(SIGNAL_METADATA_KEY, signals, target); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters