@angular/core#NgZone TypeScript Examples

The following examples show how to use @angular/core#NgZone. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: importdid.ts    From Elastos.Essentials.App with MIT License 6 votes vote down vote up
constructor(
    public router: Router,
    public zone: NgZone,
    public platform: Platform,
    private modalCtrl: ModalController,
    private identityService: IdentityService,
    private uxService: UXService,
    private translate: TranslateService,
    private popup: PopupProvider,
    public theme: GlobalThemeService,
    private events: Events,
    public element: ElementRef,
    private mnemonicKeypadService: GlobalMnemonicKeypadService
  ) {
    const navigation = this.router.getCurrentNavigation();
    if (!Util.isEmptyObject(navigation.extras.state)) {
      this.nextStepId = navigation.extras.state.enterEvent.stepId;
      //Logger.log('didsessions', 'Importdid - nextStepId', this.nextStepId);
      if (!Util.isEmptyObject(navigation.extras.state.mnemonic)) {
        this.mnemonicSentence = navigation.extras.state.mnemonic;
        this.onMnemonicSentenceChanged();
        this.readonly = true;
      }
    }
  }
Example #2
Source File: color-canvas.component.ts    From angular-material-components with MIT License 6 votes vote down vote up
constructor(protected zone: NgZone) {
    super(zone, 'color-block');
    this.formGroup = new FormGroup({
      r: new FormControl(null, [Validators.required]),
      g: new FormControl(null, [Validators.required]),
      b: new FormControl(null, [Validators.required]),
      a: new FormControl(null, [Validators.required]),
      hex: new FormControl(null, [Validators.required, Validators.pattern(matchers.hex6)]),
    });
  }
Example #3
Source File: personal-cards.page.ts    From fyle-mobile-app with MIT License 6 votes vote down vote up
constructor(
    private personalCardsService: PersonalCardsService,
    private networkService: NetworkService,
    private router: Router,
    private activatedRoute: ActivatedRoute,
    private inAppBrowser: InAppBrowser,
    private loaderService: LoaderService,
    private zone: NgZone,
    private matSnackBar: MatSnackBar,
    private snackbarProperties: SnackbarPropertiesService,
    private modalController: ModalController,
    private dateService: DateService,
    private apiV2Service: ApiV2Service,
    private platform: Platform,
    private spinnerDialog: SpinnerDialog,
    private trackingService: TrackingService
  ) {}
Example #4
Source File: logout.component.ts    From EXOS-Core with MIT License 6 votes vote down vote up
constructor(
        private ngZone: NgZone,
        public wallet: WalletService,
        private authService: AuthenticationService,
        private globalService: GlobalService,
        private apiService: ApiService,
        private appState: ApplicationStateService,
        private router: Router) {

    }
Example #5
Source File: color-picker.component.ts    From angular-material-components with MIT License 6 votes vote down vote up
constructor(private _dialog: MatDialog,
    private _overlay: Overlay,
    private _zone: NgZone,
    private _adapter: ColorAdapter,
    @Optional() private _dir: Directionality,
    @Inject(NGX_MAT_COLOR_PICKER_SCROLL_STRATEGY) scrollStrategy: any,
    @Optional() @Inject(DOCUMENT) private _document: any,
    private _viewContainerRef: ViewContainerRef) {
    this._scrollStrategy = scrollStrategy;
  }
Example #6
Source File: advanced.component.ts    From EXOS-Core with MIT License 6 votes vote down vote up
constructor(
        private electronService: ElectronService,
        private authService: AuthenticationService,
        private router: Router,
        private zone: NgZone,
        private log: Logger,
        private apiService: ApiService,
        public updateService: UpdateService,
        public appState: ApplicationStateService) {

    }
Example #7
Source File: datetime-picker.component.ts    From angular-material-components with MIT License 6 votes vote down vote up
constructor(private _dialog: MatDialog,
    private _overlay: Overlay,
    private _ngZone: NgZone,
    private _viewContainerRef: ViewContainerRef,
    @Inject(MAT_DATEPICKER_SCROLL_STRATEGY) scrollStrategy: any,
    @Optional() private _dateAdapter: NgxMatDateAdapter<D>,
    @Optional() private _dir: Directionality,
    @Optional() @Inject(DOCUMENT) private _document: any) {
    if (!this._dateAdapter) {
      throw createMissingDateImplError('NgxMatDateAdapter');
    }

    this._scrollStrategy = scrollStrategy;
  }
Example #8
Source File: datetime-picker.component.ts    From ngx-mat-datetime-picker with MIT License 6 votes vote down vote up
constructor(private _dialog: MatDialog,
    private _overlay: Overlay,
    private _ngZone: NgZone,
    private _viewContainerRef: ViewContainerRef,
    @Inject(MAT_DATEPICKER_SCROLL_STRATEGY) scrollStrategy: any,
    @Optional() private _dateAdapter: NgxMatDateAdapter<D>,
    @Optional() private _dir: Directionality,
    @Optional() @Inject(DOCUMENT) private _document: any) {
    if (!this._dateAdapter) {
      throw createMissingDateImplError('NgxMatDateAdapter');
    }

    this._scrollStrategy = scrollStrategy;
  }
Example #9
Source File: wallet.service.ts    From Elastos.Essentials.App with MIT License 6 votes vote down vote up
constructor(
        public events: Events,
        public native: Native,
        public zone: NgZone,
        public modalCtrl: ModalController,
        public translate: TranslateService,
        public localStorage: LocalStorage,
        private erc721Service: ERC721Service,
        private erc1155Service: ERC1155Service,
        private authService: AuthService,
        public popupProvider: PopupProvider,
        private prefs: GlobalPreferencesService,
        private safeService: SafeService, // Keep this - init
        private networkService: WalletNetworkService,
        private globalNetworksService: GlobalNetworksService,
        private walletNetworkService: WalletNetworkService,
        private offlineTransactionsService: OfflineTransactionsService, // Keep for init
        private didSessions: GlobalDIDSessionsService
    ) {
        WalletService.instance = this;
    }
Example #10
Source File: app-initialize.ts    From elements with MIT License 6 votes vote down vote up
appInitialize = (
  config: InoElementsConfig,
  doc: Document,
  zone: NgZone
) => {
  return (): any => {
    const win: InoElementsWindow | undefined = doc.defaultView as any;
    if (win && typeof (window as any) !== 'undefined') {
      if (didInitialize) {
        return;
      }
      didInitialize = true;

      win.inoElements = win.inoElements || {};
      win.inoElements.config = config;

      const aelFn =
        '__zone_symbol__addEventListener' in (doc.body as any)
          ? '__zone_symbol__addEventListener'
          : 'addEventListener';

      /* eslint-disable prefer-arrow/prefer-arrow-functions */
      return applyPolyfills().then(() => {
        return defineCustomElements(win, {
          exclude: [],
          syncQueue: true,
          raf,
          jmp: (h: any) => zone.runOutsideAngular(h),
          ael(elm, eventName, cb, opts) {
            (elm as any)[aelFn](eventName, cb, opts);
          },
          rel(elm, eventName, cb, opts) {
            elm.removeEventListener(eventName, cb, opts);
          },
        });
      });
    }
  };
}
Example #11
Source File: adminprovideredit.page.ts    From Elastos.Essentials.App with MIT License 6 votes vote down vote up
constructor(
    public zone: NgZone,
    public alertController:AlertController,
    private router: Router,
    private adminService: AdminService,
    private popup: PopupService,
    public theme: GlobalThemeService,
    private native: GlobalNativeService,
    private globalNav: GlobalNavService,
    private translate: TranslateService,
    // public navParams: NavParams // Err - No provider for Navparams
  ) {
    const navigation = this.router.getCurrentNavigation();
    if(navigation.extras.state) {
      const providerId = navigation.extras.state.providerId;
      Logger.log('HiveManager', 'Provider id', providerId);
      void this.init(providerId);
    }

/*     this.providerId = navParams.get('providerId');
    Logger.log('HiveManager', 'Provider id', this.providerId);
    this.init();

    this.retrieveAdminDIDPublicationStatus();
    Logger.log('HiveManager', "Editing provider:", this.managedProvider); */
  }
Example #12
Source File: start-platform-via-initializer.snippets.ts    From scion-microfrontend-platform with Eclipse Public License 2.0 6 votes vote down vote up
// end::host-app:register-initializer[]

// tag::micro-app:initializer[]
@NgModule({
  providers: [
    {
      provide: APP_INITIALIZER,
      useFactory: provideConnectToHostFn, // <1>
      deps: [NgZone], // <2>
      multi: true,
    },
  ],
  // ... other metadata omitted
})
export class AppModule {
}
Example #13
Source File: dropdown.directive.ts    From alauda-ui with MIT License 6 votes vote down vote up
constructor(
    overlay: Overlay,
    viewContainerRef: ViewContainerRef,
    elRef: ElementRef,
    renderer: Renderer2,
    cdr: ChangeDetectorRef,
    ngZone: NgZone,
  ) {
    super(overlay, viewContainerRef, elRef, renderer, cdr, ngZone);
    new DropdownActiveDirective(this, elRef, renderer).customClass = 'isActive';
    this.type = TooltipType.Plain;
    this.position = 'bottom end';
    this.trigger = TooltipTrigger.Click;
  }
Example #14
Source File: titlebar.component.ts    From WowUp with GNU General Public License v3.0 6 votes vote down vote up
public constructor(
    public electronService: ElectronService,
    private _wowUpService: WowUpService,
    private _ngZone: NgZone,
    private _snackBar: MatSnackBar,
    private _translateService: TranslateService
  ) {
    const windowMaximizedSubscription = this.electronService.windowMaximized$.subscribe((maximized) => {
      this._ngZone.run(() => (this.isMaximized = maximized));
    });

    this._subscriptions = [windowMaximizedSubscription];

    this.electronService.on(IPC_WINDOW_ENTER_FULLSCREEN, () => {
      this.isFullscreen = true;
      const localeKey = this.electronService.isMac ? "APP.FULLSCREEN_SNACKBAR.MAC" : "APP.FULLSCREEN_SNACKBAR.WINDOWS";
      const message = this._translateService.instant(localeKey);
      this._snackBarRef = this._snackBar.openFromComponent(CenteredSnackbarComponent, {
        duration: 5000,
        panelClass: ["wowup-snackbar", "text-1"],
        data: {
          message,
        },
        verticalPosition: "top",
      });
    });

    this.electronService.on(IPC_WINDOW_LEAVE_FULLSCREEN, () => {
      this.isFullscreen = false;
      this._snackBarRef?.dismiss();
      this._snackBarRef = undefined;
    });
  }
Example #15
Source File: timeline.component.ts    From VIR with MIT License 6 votes vote down vote up
constructor(
    private readonly dataStore: DataStore,
    private readonly dataAnalyzer: DataAnalyzer,
    private readonly changeDetectorRef: ChangeDetectorRef,
    private readonly zone: NgZone,
    private readonly dialog: MatDialog,
    readonly home: HomeComponent,
  ) {
    this.viewRange = 'month' // Ensure row is updated
    this.todayDayID = dataStore.getCurrentDayID()
  }
Example #16
Source File: home.ts    From Elastos.Essentials.App with MIT License 6 votes vote down vote up
constructor(
        public translate: TranslateService,
        private nav: GlobalNavService,
        public theme: GlobalThemeService,
        public httpClient: HttpClient,
        public zone: NgZone,
        private platform: Platform,
        private globalStartupService: GlobalStartupService,
        private globalIntentService: GlobalIntentService,
        private globalStorageService: GlobalStorageService,
        public dappbrowserService: DappBrowserService,
        public walletNetworkService: WalletNetworkService,
        private walletNetworkUIService: WalletNetworkUIService,
        private favoritesService: FavoritesService
    ) {
        this.initDapps();
    }
Example #17
Source File: alert-list.component.ts    From VIR with MIT License 6 votes vote down vote up
constructor(
    private readonly changeDetectorRef: ChangeDetectorRef,
    private readonly dataStore: DataStore,
    private readonly dataAnalyzer: DataAnalyzer,
    private readonly dialog: MatDialog,
    private readonly zone: NgZone,
    private readonly home: HomeComponent,
  ) {
    this.alertActionCtx = {
      showItemInItems: (itemID: ItemID) => {
        this.home.showInItems(itemID)
      },
      showItemInQueue: (itemID: ItemID) => {
        this.home.showInQueue(itemID)
      },
      editItem: (itemID: ItemID) => {
        const item = this.dataStore.getItem(itemID)
        if (item === undefined) return
        const dialogRef = this.dialog.open(ItemDetailsComponent, {
          width: ItemDetailsComponent.DIALOG_WIDTH,
          data: {item},
          hasBackdrop: true,
          disableClose: false,
          autoFocus: false,
        })
      },
      dataStore: this.dataStore,
    }
  }
Example #18
Source File: should-call.ts    From ng-event-plugins with Apache License 2.0 6 votes vote down vote up
/**
 * TODO: This will not be needed when markDirty becomes stable API
 */
export function shouldCall<T>(predicate: Predicate<T>): MethodDecorator {
    return (_, key, desc: PropertyDescriptor) => {
        const {value} = desc;

        desc.value = function (this: T, ...args: any[]) {
            const zone = arguments[0];

            if (zone instanceof NgZone) {
                Object.defineProperty(this, key, {
                    value(this: T, ...args: any[]) {
                        if (predicate.apply(this, args)) {
                            zone.run(() => {
                                value.apply(this, args);
                            });
                        }
                    },
                });
            } else if (predicate.apply(this, args)) {
                value.apply(this, args);
            }
        };
    };
}
Example #19
Source File: staking-lp.service.ts    From rubic-app with GNU General Public License v3.0 6 votes vote down vote up
constructor(
    private readonly web3PublicService: PublicBlockchainAdapterService,
    private readonly volumeApiService: VolumeApiService,
    private readonly authService: AuthService,
    private readonly tokensService: TokensService,
    private readonly errorService: ErrorsService,
    private readonly httpClient: HttpClient,
    private readonly zone: NgZone
  ) {
    this.getStakingTokenPrice();
  }
Example #20
Source File: vendor-location.page.ts    From Uber-ServeMe-System with MIT License 6 votes vote down vote up
constructor(
    public toastCtrl: ToastController,
    private platform: Platform,
    private loadingCtrl: LoadingController,
    private ngZone: NgZone,
    public route: Router,
    public activateRoute: ActivatedRoute,
    public nav: NavController,
    public user: UserService,
    public homeService: HomeServiceService,
    public afstore: AngularFirestore,
    public toast: ToastController,
    public router: Router,
  ) {
  }
Example #21
Source File: app.component.ts    From xBull-Wallet with GNU Affero General Public License v3.0 6 votes vote down vote up
constructor(
    @Inject(ENV)
    private readonly env: typeof environment,
    private readonly settingsService: SettingsService,
    private readonly settingsQuery: SettingsQuery,
    private readonly walletsAccountsService: WalletsAccountsService,
    private readonly walletsAccountsQuery: WalletsAccountsQuery,
    private readonly walletsOperationsQuery: WalletsOperationsQuery,
    private readonly alertsLabelsService: AlertsLabelsService,
    private readonly horizonApisQuery: HorizonApisQuery,
    private readonly route: ActivatedRoute,
    @Inject(DOCUMENT)
    private readonly document: Document,
    private readonly renderer2: Renderer2,
    private readonly globalsService: GlobalsService,
    private readonly ngZone: NgZone,
    private readonly translateService: TranslateService,
  ) { }
Example #22
Source File: header.component.ts    From rubic-app with GNU General Public License v3.0 6 votes vote down vote up
constructor(
    @Inject(PLATFORM_ID) platformId: Object,
    private readonly headerStore: HeaderStore,
    private readonly authService: AuthService,
    private readonly iframeService: IframeService,
    private readonly cdr: ChangeDetectorRef,
    private readonly storeService: StoreService,
    private readonly router: Router,
    private readonly errorService: ErrorsService,
    private readonly queryParamsService: QueryParamsService,
    private readonly swapFormService: SwapFormService,
    private readonly swapsService: SwapsService,
    private readonly myTradesService: MyTradesService,
    private readonly tokensService: TokensService,
    @Inject(WINDOW) private readonly window: Window,
    @Inject(DOCUMENT) private readonly document: Document,
    @Self() private readonly destroy$: TuiDestroyService,
    private readonly gtmService: GoogleTagManagerService,
    private readonly zone: NgZone
  ) {
    this.loadUser();
    this.advertisementType = 'default';
    this.currentUser$ = this.authService.getCurrentUser();
    this.isMobileMenuOpened$ = this.headerStore.getMobileMenuOpeningStatus();
    this.isMobile$ = this.headerStore.getMobileDisplayStatus();
    this.headerStore.setMobileDisplayStatus(this.window.innerWidth <= this.headerStore.mobileWidth);
    if (isPlatformBrowser(platformId)) {
      this.zone.runOutsideAngular(() => {
        this.setNotificationPosition();
        this.window.onscroll = () => {
          this.setNotificationPosition();
        };
      });
    }
    this.swapType$ = this.swapsService.swapMode$;
  }
Example #23
Source File: scanned-item-editor.component.ts    From pantry_party with Apache License 2.0 6 votes vote down vote up
constructor(
    private stateTransfer: StateTransferService,
    private ngZone: NgZone,
    private routedExtensions: RouterExtensions,
    private grocyService: GrocyService,
    private _fb: FormBuilder
  ) {
    this.grocyService.locations().subscribe(loc => this.locationsArr = loc);
    this.grocyService.allProducts().subscribe(prods => this.productsArr = prods);

    const state = this.stateTransfer.readAndClearState();

    if (state && state.type === "scannedItemEdit") {
      this.originalScannedItem = state.scannedItem;

      this.form.setValue({
        quantity: this.originalScannedItem.quantity,
        location: this.originalScannedItem.location || null,
        product: this.originalScannedItem.grocyProduct || null,
        bestByDate: dateStringParser(this.originalScannedItem.bestBeforeDate)
      });

      this.selectionCallback = state.callback;
    }

  }
Example #24
Source File: angular-zone-message-client-decorator.snippets.ts    From scion-microfrontend-platform with Eclipse Public License 2.0 6 votes vote down vote up
// end::intent-client-decorator[]

// tag::emit-inside-angular[]
function synchronizeWithAngular<T>(zone: NgZone): MonoTypeOperatorFunction<T> {
  return pipe(
    subscribeInside(continueFn => zone.runOutsideAngular(continueFn)),
    observeInside(continueFn => zone.run(continueFn)),
  );
}