rs
21 November 2020 14:42
#1
I’m trying the following to override some behavior of MonacoWorkspace:
unbind(MonacoWorkspace); ----> exception here !
bind(CustomMonacoWorkspace).toSelf().inSingletonScope();
rebind(Workspace).toService(CustomMonacoWorkspace);
rebind(MonacoWorkspace).toService(CustomMonacoWorkspace);
but, when i run the app, the browser console shows an exception that MonacoWorkspace ‘cannot unbind’.
Can anyone guide me regrding this ? thanks in advance.
It should work. MonacoWorkspace
is bound to self:
bind(MonacoToProtocolConverter).toSelf().inSingletonScope();
bind(ProtocolToMonacoConverter).toSelf().inSingletonScope();
bind(MonacoLanguages).toSelf().inSingletonScope();
rebind(LanguageService).toService(MonacoLanguages);
bind(WorkspaceSymbolCommand).toSelf().inSingletonScope();
for (const identifier of [CommandContribution, KeybindingContribution, QuickOpenContribution]) {
bind(identifier).toService(WorkspaceSymbolCommand);
}
bind(MonacoWorkspace).toSelf().inSingletonScope();
bind(MonacoConfigurationService).toDynamicValue(({ container }) =>
createMonacoConfigurationService(container)
).inSingletonScope();
bind(monaco.contextKeyService.ContextKeyService).toDynamicValue(({ container }) =>
new monaco.contextKeyService.ContextKeyService(container.get(MonacoConfigurationService))
).inSingletonScope();
bind(MonacoBulkEditService).toSelf().inSingletonScope();
bind(MonacoEditorService).toSelf().inSingletonScope();
bind(MonacoTextModelService).toSelf().inSingletonScope();
Maybe it is just a DI container loading issue and there is a problem with the order. Make sure, your module explicitly depends on @theia/monaco
.
Your binding can be simplified, by the way:
bind(MyMonacoWorkspace).toSelf().inSingletonScope();
rebind(MonacoWorkspace).toService(MyMonacoWorkspace);
rs
26 November 2020 10:29
#3
Thank you very much, @kittaakos