-
-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(runtime): making resources into an explicit concept again
- Loading branch information
1 parent
3d62b7a
commit 559e008
Showing
5 changed files
with
88 additions
and
34 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { Constructable } from "../kernel/interfaces"; | ||
import { IRegistry } from "../kernel/di"; | ||
|
||
function resourceName(this: IResourceKind, name: string) { | ||
return `${this.name}:${name}`; | ||
} | ||
|
||
function isType(this: IResourceKind, type: Function) { | ||
return (<any>type).kind === this; | ||
} | ||
|
||
export interface IResourceDescription { | ||
name: string; | ||
} | ||
|
||
export interface IResourceKind { | ||
name: 'attribute' | 'element' | 'value-converter' | 'binding-behavior'; | ||
key(name: string): string; | ||
isType(type: Function): boolean; | ||
} | ||
|
||
export interface IResourceType<T = {}> extends Constructable<T>, IRegistry { | ||
kind: IResourceKind; | ||
description: IResourceDescription; | ||
} | ||
|
||
export const Resource = { | ||
attribute: { | ||
name: 'attribute', | ||
key: resourceName, | ||
isType: isType | ||
} as IResourceKind, | ||
element: { | ||
name: 'element', | ||
key: resourceName, | ||
isType: isType | ||
} as IResourceKind, | ||
valueConverter: { | ||
name: 'value-converter', | ||
key: resourceName, | ||
isType: isType | ||
} as IResourceKind, | ||
bindingBehavior: { | ||
name: 'binding-behavior', | ||
key: resourceName, | ||
isType: isType | ||
} as IResourceKind | ||
}; |
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
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