Register Models with Dynamic converter
Fix `RemoteConnector.prototype.resolve` to register new models with strong-remoting's `Dynamic` type resolver. Before this change, if loopback-connector-remoting ended up with its own copy of strong-remoting, then the responses were not converted from plain objects to model instances, because model converters were registered with the other instances of strong-remoting. This has a side-effect that when there is only one strong-remoting instance in the app, then there will be multiple converters registered for the same model. Since the code performing conversion takes into account the first model only, this should not pose any issues.
This commit is contained in:
parent
5b721fe016
commit
0fd7bf06b5
|
@ -77,6 +77,11 @@ RemoteConnector.prototype.resolve = function(Model) {
|
||||||
createProxyMethod(Model, remotes, remoteMethod);
|
createProxyMethod(Model, remotes, remoteMethod);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// setup a remoting type converter for this model
|
||||||
|
remotes.defineType(Model.modelName, function(val) {
|
||||||
|
return val ? new Model(val) : val;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
function createProxyMethod(Model, remotes, remoteMethod) {
|
function createProxyMethod(Model, remotes, remoteMethod) {
|
||||||
|
|
Loading…
Reference in New Issue