Comparing version 0.1.23 to 0.1.24
@@ -9,2 +9,3 @@ import * as Tests from "./Tests"; | ||
tree: Tests.TestTree; | ||
testTransient: Tests.TestTransient; | ||
leaf: Tests.TestLeaf; | ||
@@ -11,0 +12,0 @@ trees: Array<Tests.TestTree>; |
@@ -109,2 +109,5 @@ "use strict"; | ||
__decorate([ | ||
reob.Type("TestTransient") | ||
], TestPerson.prototype, "testTransient", void 0); | ||
__decorate([ | ||
reob.Type("TestLeaf") | ||
@@ -111,0 +114,0 @@ ], TestPerson.prototype, "leaf", void 0); |
@@ -11,2 +11,3 @@ /** | ||
export * from "./TestTree"; | ||
export * from "./TestTransient"; | ||
export * from "./TestPersonCollection"; | ||
@@ -13,0 +14,0 @@ export * from "./TestCarCollection"; |
@@ -15,2 +15,3 @@ /** | ||
__export(require("./TestTree")); | ||
__export(require("./TestTransient")); | ||
__export(require("./TestPersonCollection")); | ||
@@ -17,0 +18,0 @@ __export(require("./TestCarCollection")); |
@@ -958,2 +958,16 @@ "use strict"; | ||
}); | ||
it("knows post create function names", function () { | ||
var names = reob.Reflect.getPostCreateFunctionNames(Tests.TestTransient); | ||
expect(names).toBeDefined(); | ||
expect(names.length).toBe(1); | ||
expect(names[0]).toBe("initialize"); | ||
}); | ||
it("calls functions that are annotated with 'PostCreate' when objects get deserialized", function () { | ||
var s = new reob.Serializer(); | ||
var t1 = new Tests.TestPerson("tp1"); | ||
t1.testTransient = new Tests.TestTransient("12345"); | ||
var doc = s.toDocument(t1); | ||
var t2 = s.toObject(doc, undefined, Tests.TestPerson); | ||
expect(t2.testTransient.ignoredProperty).toBe("hello 12345"); | ||
}); | ||
it("can register to during-update-events and the event listener receives all the correct data.", function (done) { | ||
@@ -960,0 +974,0 @@ var l = spyOnAndCallThrough(function (updateEvent) { |
@@ -64,2 +64,3 @@ import * as reob from "./reob"; | ||
export declare function Remote(p1: any, p2?: any, d?: any): any; | ||
export declare function PostCreate(t: any, functionName: string, objectDescriptor: any): void; | ||
export declare class Reflect { | ||
@@ -69,2 +70,3 @@ static getMethodOptions(typeClass: reob.TypeClass<any>, functionName: string): IMethodOptions; | ||
static getRemoteFunctionNames<T extends Object>(typeClass: reob.TypeClass<any>): Array<string>; | ||
static getPostCreateFunctionNames<T extends Object>(typeClass: reob.TypeClass<any>): Array<string>; | ||
static getRemoteFunctionNamesByObject<T extends Object>(o: any): Array<string>; | ||
@@ -71,0 +73,0 @@ static getClass<T extends Object>(o: T): reob.TypeClass<T>; |
@@ -253,2 +253,6 @@ "use strict"; | ||
exports.Remote = Remote; | ||
function PostCreate(t, functionName, objectDescriptor) { | ||
Reflect.setPropertyProperty(t, functionName, "postCreate", true); | ||
} | ||
exports.PostCreate = PostCreate; | ||
var Reflect = (function () { | ||
@@ -285,2 +289,5 @@ function Reflect() { | ||
}; | ||
Reflect.getPostCreateFunctionNames = function (typeClass) { | ||
return Reflect.getPropertyNamesOfPropertiesThatHaveAProperty(typeClass, "postCreate"); | ||
}; | ||
Reflect.getRemoteFunctionNamesByObject = function (o) { | ||
@@ -287,0 +294,0 @@ var cls = Reflect.getClass(o); |
@@ -90,4 +90,5 @@ "use strict"; | ||
// instantiate the new object | ||
if (f && f.prototype) | ||
if (f && f.prototype) { | ||
o = Object.create(f.prototype); | ||
} | ||
else | ||
@@ -131,2 +132,9 @@ o = {}; | ||
} | ||
// call "postCreate" functions | ||
var postCreateFunctionNames = Annotations_1.Reflect.getPostCreateFunctionNames(f); | ||
if (postCreateFunctionNames) { | ||
postCreateFunctionNames.forEach(function (functionName) { | ||
o[functionName](); | ||
}); | ||
} | ||
} | ||
@@ -133,0 +141,0 @@ return o; |
{ | ||
"name": "reob", | ||
"description": "Remote objects - Create backends for one page web apps with ease. Uses mongo and express.", | ||
"version": "0.1.23", | ||
"version": "0.1.24", | ||
"repository": "https://github.com/bvanheukelom/reob", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
498821
139
5008