How to use the inversify.inject function in inversify

To help you get started, we’ve selected a few inversify examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github eclipse / sprotty / src / base / views / viewer-cache.ts View on Github external
import { SModelRoot } from "../model/smodel";
import { TYPES } from "../types";
import { Action } from "../actions/action";
import { AnimationFrameSyncer } from "../animations/animation-frame-syncer";
import { IViewer } from "./viewer";

/**
 * Updating the view is rather expensive, and it doesn't make sense to calculate
 * more then one update per animation (rendering) frame. So this class batches
 * all incoming model changes and only renders the last one when the next animation
 * frame comes.
 */
@injectable()
export class ViewerCache implements IViewer {

    @inject(TYPES.IViewer) protected delegate: IViewer;
    @inject(TYPES.AnimationFrameSyncer) protected syncer: AnimationFrameSyncer;

    protected cachedModel?: SModelRoot;

    update(model: SModelRoot, cause?: Action): void {
        if (cause !== undefined) {
            // Forward the update immediately in order to pass the cause action
            this.delegate.update(model, cause);
            this.cachedModel = undefined;
        } else {
            const isCacheEmpty = this.cachedModel === undefined;
            this.cachedModel = model;
            if (isCacheEmpty) {
                this.scheduleUpdate();
            }
        }
github eclipse-theia / theia / packages / scm / src / browser / scm-widget.tsx View on Github external
if (groups) {
                groups.forEach(group => group.resources.forEach(resource => resources.push(resource)));
                this.scmNodes = resources;
            }
        }
        this.selectNode(change);
    }
    protected readonly handleEnter: () => void;

    @inject(ScmTitleCommandRegistry) protected readonly scmTitleRegistry: ScmTitleCommandRegistry;
    @inject(ScmResourceCommandRegistry) protected readonly scmResourceCommandRegistry: ScmResourceCommandRegistry;
    @inject(ScmGroupCommandRegistry) protected readonly scmGroupCommandRegistry: ScmGroupCommandRegistry;
    @inject(ScmService) private readonly scmService: ScmService;
    @inject(CommandRegistry) private readonly commandRegistry: CommandRegistry;
    @inject(ApplicationShell) protected readonly shell: ApplicationShell;
    @inject(ContextMenuRenderer) protected readonly contextMenuRenderer: ContextMenuRenderer;
    @inject(ScmAvatarService) protected readonly avatarService: ScmAvatarService;
    @inject(StorageService) protected readonly storageService: StorageService;

    constructor() {
        super();
        this.id = 'theia-scmContainer';
        this.addClass('theia-scm');
        this.scrollContainer = ScmWidget.Styles.GROUPS_CONTAINER;

        this.update();
    }

    @postConstruct()
    protected init() {
        const changeHandler = (repository: ScmRepository) => {
            repository.provider.onDidChangeResources(() => {
github eclipse-theia / theia / packages / typescript / src / browser / typescript-frontend-contribution.ts View on Github external
@injectable()
export class TypeScriptFrontendContribution implements FrontendApplicationContribution, CommandContribution, MenuContribution, KeybindingContribution {

    @inject(StatusBar)
    protected readonly statusBar: StatusBar;

    @inject(EditorManager)
    protected readonly editorManager: EditorManager;

    @inject(QuickPickService)
    protected readonly quickPickService: QuickPickService;

    @inject(TypeScriptClientContribution)
    protected readonly clientContribution: TypeScriptClientContribution;

    @inject(FileSystemWatcher)
    protected readonly fileSystemWatcher: FileSystemWatcher;

    @inject(LabelProvider)
    protected readonly labelProvider: LabelProvider;

    @inject(StorageService)
    protected readonly storage: StorageService;

    @postConstruct()
    protected init(): void {
        this.fileSystemWatcher.onDidMove(event => this.renameFile(event));
    }

    onStart(): void {
        this.restore();
        this.updateStatusBar();
github eclipse-theia / theia / packages / debug / src / browser / editor / debug-hover-source.tsx View on Github external
* with the GNU Classpath Exception which is available at
 * https://www.gnu.org/software/classpath/license.html.
 *
 * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
 ********************************************************************************/

import * as React from 'react';
import { TreeSource, TreeElement } from '@theia/core/lib/browser/source-tree';
import { ExpressionContainer, ExpressionItem, DebugVariable } from '../console/debug-console-items';
import { DebugSessionManager } from '../debug-session-manager';
import { injectable, inject } from 'inversify';

@injectable()
export class DebugHoverSource extends TreeSource {

    @inject(DebugSessionManager)
    protected readonly sessions: DebugSessionManager;

    protected _expression: ExpressionItem | DebugVariable | undefined;
    get expression(): ExpressionItem | DebugVariable | undefined {
        return this._expression;
    }

    protected elements: TreeElement[] = [];
    getElements(): IterableIterator {
        return this.elements[Symbol.iterator]();
    }

    protected renderTitle(element: ExpressionItem | DebugVariable): React.ReactNode {
        return <div title="{element.value}">{element.value}</div>;
    }
github tierratelematics / prettygoat / scripts / routing / ExpressStatePublisher.ts View on Github external
constructor(@inject("IProjectionRouter") private router:IProjectionRouter,
                @inject("IProjectionSelector") private projectionSelector:IProjectionSelector,
                @inject("IProjectionRegistry") private projectionRegistry:IProjectionRegistry) {

    }
github DonJayamanne / gitHistoryVSCode / src / adapter / repository / factory.ts View on Github external
    constructor(@inject(IGitCommandExecutor) private gitCmdExecutor: IGitCommandExecutor,
        @inject(ILogParser) private logParser: ILogParser,
        @inject(IGitArgsService) private gitArgsService: IGitArgsService,
        @inject(IServiceContainer) private serviceContainer: IServiceContainer) {

    }
    public async createGitService(workspaceRoot: string, resource: Uri | string): Promise {
github uprtcl / js-uprtcl / packages / cortex / src / services / discovery.service.ts View on Github external
constructor(
    @inject(DiscoveryTypes.Cache) protected cache: CacheService,
    @inject(DiscoveryTypes.MultiSource) protected multiSource: MultiSourceService
  ) {
    this.cachedRemote = new CachedSourceService(cache, multiSource);
  }
github eclipse-theia / theia / packages / keymaps / src / browser / keymaps-service.ts View on Github external
* The actual keybinding.
     */
    keybinding: string,
    /**
     * The keybinding context.
     */
    context: string,
}

@injectable()
export class KeymapsService {

    @inject(ResourceProvider)
    protected readonly resourceProvider: ResourceProvider;

    @inject(KeybindingRegistry)
    protected readonly keyBindingRegistry: KeybindingRegistry;

    @inject(OpenerService)
    protected readonly opener: OpenerService;

    @inject(KeymapsParser)
    protected readonly parser: KeymapsParser;

    protected readonly changeKeymapEmitter = new Emitter();
    onDidChangeKeymaps = this.changeKeymapEmitter.event;

    protected resource: Resource;

    /**
     * Initialize the keybinding service.
     */
github RiseVision / rise-node / packages / core-transactions / src / api / httpApi.ts View on Github external
@inject(Symbols.generic.zschema)
  public schema: z_schema;

  @inject(Symbols.helpers.timeToEpoch)
  public timeToEpoch: ITimeToEpoch;

  @inject(Symbols.generic.hookSystem)
  private hookSystem: WordPressHookSystem;

  @inject(Symbols.modules.accounts)
  private accountsModule: IAccountsModule;
  @inject(Symbols.modules.blocks)
  private blocksModule: IBlocksModule;
  @inject(TXSymbols.module)
  private transactionsModule: ITransactionsModule;
  @inject(Symbols.modules.system)
  private systemModule: ISystemModule;

  @inject(ModelSymbols.model)
  @named(TXSymbols.models.model)
  private TXModel: typeof ITransactionsModel;
  @inject(ModelSymbols.model)
  @named(ModelSymbols.names.accounts)
  private AccountsModel: typeof IAccountsModel;

  @inject(TXSymbols.logic)
  private txLogic: ITransactionLogic;

  @inject(TXSymbols.pool)
  private pool: TransactionPool;

  @Get()
github microsoft / vscode-chrome-debug-core / src / chrome / internal / features / skipFiles.ts View on Github external
constructor(
        @inject(TYPES.EventsConsumedByConnectedCDA) private readonly _dependencies: EventsConsumedBySkipFilesLogic,
        @inject(TYPES.CDTPDiagnostics) private readonly chrome: CDTPDiagnostics,
        @inject(TYPES.DeleteMeScriptsRegistry) private readonly _scriptsRegistry: DeleteMeScriptsRegistry,
        @inject(new LazyServiceIdentifer(() => TYPES.StackTracesLogic)) private readonly stackTracesLogic: StackTracesLogic,
        @inject(TYPES.BaseSourceMapTransformer) private readonly sourceMapTransformer: BaseSourceMapTransformer,
        @inject(TYPES.BasePathTransformer) private readonly pathTransformer: BasePathTransformer,
    ) { }
}