Question about video 29 (using the Eclipse Context) #1034

CLOSED
Submitted 2 years ago

Hi, At the end of the video first you use MApplication context (the highest lvl of Hierarchy) then MWindow context, to do the same thing. What’s the difference between them, when we should use the MApplication, when the MWindow? Thank’s again. NK

Comments

  2 years ago

Hi, the context is a hierarchy and if you use dependency injection you will get the object from the closest context which contains the key / value pair. So if you are in a part and use @Inject you will get the object window specific if stored in a window and if not you will get the object for your application.

Both is useful, e.g. the UI selection is stored in the window context, as selections are typical window specific. Other objects like the model service are stored in the application context, as these are typical singletons.

Please login to write a comment.