Support async app loading - #5
Conversation
There was a problem hiding this comment.
Please omit the boilerplate code to keep the example short.
Example:
myAsyncThing.run(function(metadata) {
// Configure LoopBack models and datasources
app.boot(__dirname);
//use the model metadata to introspectively register new models
myAsyncThing.buildModels(metadata);
// other configuration as scaffolded by `slc lb project`
app.use(loopback.favicon());
// etc.
app.enableAuth();
//app API is ready to go -- time to alert anyone who cares (lookin' at you grunt-loopback-angular)
doOnReady();
if(require.main === module) {
// start the http server
}
});There was a problem hiding this comment.
not a problem... update to PR coming
|
Hi @ryedin, thank you for the pull request. The feature makes sense. See the comments above for things to improve/fix. |
|
Can one of the admins verify this patch? To accept patch and trigger a build add comment ".ok\W+to\W+test." |
|
PR updated with recommended changes. |
|
Excellent, the patch looks much better now.
Makes sense. IMO the extra complexity needed to implement this outweigh the benefits.
Here are few possible solutions:
|
There was a problem hiding this comment.
test:sync and test:async are no longer needed, the async test can be defined in the same way as default_options and custom_options:
loopback_angular: {
options: {
input: 'test/fixtures/app.js'
},
default_options: {
options: {
output: 'tmp/default_options'
}
},
custom_options: {
options: {
output: 'tmp/custom_options',
ngModuleName: 'customServices',
apiUrl: 'http://custom/api/'
}
},
async_app: {
options: {
input: 'test/fixtures/app-async.js',
output: 'tmp/async_app'
}
}
},The nodeunit test code can go to test/loopback_angular_test.js.
Mayhap I am missing the point of separating sync & async tests. What benefits do you see in splitting sync and async tests?
|
Hey @ryedin, what's the status of this pull request? Are you still keen to finish it up? Note that loopback-boot now supports async booting process OOTB, see strongloop/loopback-boot#77 and strongloop/loopback-boot#50 |
|
Can one of the admins verify this patch? To accept patch and trigger a build add comment ".ok\W+to\W+test." |
|
This pull request seems to be abandoned, I am closing it. Feel free to reopen when you are ready to update and finish it. |
This is needed for the cases where the app wants to go fetch metadata during the loopback startup phase. The main use case is to grab data from a remote source in order to use introspection to build the models.