You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would app.get() be preferred since it's non-blocking? AFAIK, app.getSync() exists only for use in a constructor, which can't be async-ed.
Not exactly. The difference between getSync and get is whether the binding can be resolved synchronously or asynchronously. If the binding resolution returns a promise by itself or its dependencies, getSync will throw an error. Please await ctx.get(...) works for both cases.
From performance perspective, getSync is more efficient than get. If the binding produces a value synchronously, using get() is the same as getSync() except the returned value is wrapped in a Promise.
Activity
raymondfeng commentedon Sep 21, 2020
LB4 model classes are bound the
Applicationcontext. You can use dependency injection or service locator to get a model class by name:achrinza commentedon Sep 23, 2020
Would
app.get()be preferred since it's non-blocking? AFAIK,app.getSync()exists only for use in a constructor, which can't beasync-ed.raymondfeng commentedon Sep 23, 2020
Not exactly. The difference between
getSyncandgetis whether the binding can be resolved synchronously or asynchronously. If the binding resolution returns a promise by itself or its dependencies,getSyncwill throw an error. Pleaseawait ctx.get(...)works for both cases.From performance perspective,
getSyncis more efficient thanget. If the binding produces a value synchronously, usingget()is the same asgetSync()except the returned value is wrapped in a Promise.