Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

feature(annotations): add ES7 decorator functions #104

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 43 additions & 1 deletion src/annotations.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,42 @@ function readAnnotations(fn) {
return collectedAnnotations;
}

// Decorator versions of annotation classes
function inject(...tokens) {
return function(fn) {
annotate(fn, new Inject(...tokens));
};
}

function inject(...tokens) {
return function(fn) {
annotate(fn, new Inject(...tokens));
};
}

function injectPromise(...tokens) {
return function(fn) {
annotate(fn, new InjectPromise(...tokens));
};
}

function injectLazy(...tokens) {
return function(fn) {
annotate(fn, new InjectLazy(...tokens));
};
}

function provide(...tokens) {
return function(fn) {
annotate(fn, new Provide(...tokens));
};
}

function providePromise(...tokens) {
return function(fn) {
annotate(fn, new ProvidePromise(...tokens));
};
}

export {
annotate,
Expand All @@ -162,5 +198,11 @@ export {
Provide,
ProvidePromise,
ClassProvider,
FactoryProvider
FactoryProvider,

inject,
injectPromise,
injectLazy,
provide,
providePromise,
};
7 changes: 6 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,10 @@ export {
SuperConstructor,
TransientScope,
ClassProvider,
FactoryProvider
FactoryProvider,
inject,
injectPromise,
injectLazy,
provide,
providePromise
} from './annotations';