How to use the @nativescript/core/application.on function in @nativescript/core

To help you get started, we’ve selected a few @nativescript/core 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 EddyVerbruggen / nativescript-bluetooth / demo / app / test-page-model.ts View on Github external
constructor(navContext) {
        super();
        this._bluetooth.debug = false;
        this.peripheral = navContext.peripheral;
        this.advertismentData = navContext.peripheral.advertismentData as AdvertismentData;
        console.log('peripheral', JSON.stringify(this.peripheral));
        console.log('advertismentData', JSON.stringify(this.advertismentData));
        console.log('serviceData', JSON.stringify(this.advertismentData.serviceData));
        console.log('uuids', this.advertismentData.serviceUUIDs);
        console.log('txPowerLevel', this.advertismentData.txPowerLevel);

        applicationOn(suspendEvent, this.onAppPause, this);
        applicationOn(resumeEvent, this.onAppResume, this);
        // console.log('localName', this.advertismentData.localName);
        // console.log('serviceUUIDs', this.advertismentData.serviceUUIDs);
        // console.log('txPowerLevel', this.advertismentData.txPowerLevel);
        // console.log('flags', this.advertismentData.flags);
        // console.log('manufacturerId', this.advertismentData.manufacturerId);
        // console.log('manufacturerData', this.advertismentData.manufacturerData);
        // console.log('serviceData', this.advertismentData.serviceData);
    }
    onAppResume(args: ApplicationEventData) {
github Notalib / nativescript-accessibility-ext / src / utils / FontScaleObservable.android.ts View on Github external
function setupConfigListener() {
  nsApp.off(nsApp.launchEvent, setupConfigListener);

  const context = nsApp.android && (nsApp.android.context as android.content.Context);

  if (!context) {
    nsApp.on(nsApp.launchEvent, setupConfigListener);

    return;
  }

  useAndroidFontScale();

  let configChangedCallback = new android.content.ComponentCallbacks2({
    onLowMemory() {
      // Dummy
    },
    onTrimMemory() {
      // Dummy
    },
    onConfigurationChanged(newConfig: android.content.res.Configuration) {
      fontScaleChanged(Number(newConfig.fontScale));
    },
github Notalib / nativescript-accessibility-ext / src / utils / FontScaleObservable.android.ts View on Github external
useAndroidFontScale();

  let configChangedCallback = new android.content.ComponentCallbacks2({
    onLowMemory() {
      // Dummy
    },
    onTrimMemory() {
      // Dummy
    },
    onConfigurationChanged(newConfig: android.content.res.Configuration) {
      fontScaleChanged(Number(newConfig.fontScale));
    },
  });

  context.registerComponentCallbacks(configChangedCallback);
  nsApp.on(nsApp.resumeEvent, useAndroidFontScale);
}
github Notalib / nativescript-accessibility-ext / src / utils / FontScaleObservable.ios.ts View on Github external
}

  function useIOSFontScale() {
    if (nsApp.ios.nativeApp) {
      contentSizeUpdated(nsApp.ios.nativeApp.preferredContentSizeCategory);
    } else {
      fontScaleChanged(1);
    }
  }

  const fontSizeObserver = nsApp.ios.addNotificationObserver(UIContentSizeCategoryDidChangeNotification, (args) => {
    const fontSize = args.userInfo.valueForKey(UIContentSizeCategoryNewValueKey);
    contentSizeUpdated(fontSize);
  });

  nsApp.on(nsApp.exitEvent, () => {
    nsApp.ios.removeNotificationObserver(fontSizeObserver, UIContentSizeCategoryDidChangeNotification);
    internalObservable = null;

    nsApp.off(nsApp.resumeEvent, useIOSFontScale);
  });

  nsApp.on(nsApp.resumeEvent, useIOSFontScale);

  useIOSFontScale();
}
github Notalib / nativescript-accessibility-ext / src / utils / FontScaleObservable.ios.ts View on Github external
}
  }

  const fontSizeObserver = nsApp.ios.addNotificationObserver(UIContentSizeCategoryDidChangeNotification, (args) => {
    const fontSize = args.userInfo.valueForKey(UIContentSizeCategoryNewValueKey);
    contentSizeUpdated(fontSize);
  });

  nsApp.on(nsApp.exitEvent, () => {
    nsApp.ios.removeNotificationObserver(fontSizeObserver, UIContentSizeCategoryDidChangeNotification);
    internalObservable = null;

    nsApp.off(nsApp.resumeEvent, useIOSFontScale);
  });

  nsApp.on(nsApp.resumeEvent, useIOSFontScale);

  useIOSFontScale();
}
github Notalib / nativescript-accessibility-ext / src / utils / utils.ios.ts View on Github external
);

    nsApp.on(nsApp.exitEvent, () => {
      if (nativeObserver) {
        nsApp.ios.removeNotificationObserver(nativeObserver, UIAccessibilityVoiceOverStatusChanged);
      }

      nativeObserver = null;
      if (sharedA11YObservable) {
        sharedA11YObservable.removeEventListener(Observable.propertyChangeEvent);
        sharedA11YObservable = null;
      }
    });
  }

  nsApp.on(nsApp.resumeEvent, () => sharedA11YObservable.set('isAccessibilityServiceEnabled', isAccessibilityServiceEnabled()));

  return sharedA11YObservable;
}
github Notalib / nativescript-accessibility-ext / src / angular / data / a11y-service-enabled.ts View on Github external
constructor() {
    super(isAccessibilityServiceEnabled());

    nsApp.on(nsApp.resumeEvent, this.resumeEvent, this);

    this.tnsObs.on(AccessibilityServiceEnabledObservable.propertyChangeEvent, this.tnsPropertyValueChanged, this);
  }
github Notalib / nativescript-accessibility-ext / src / utils / utils.ios.ts View on Github external
function ensureStateListener() {
  if (sharedA11YObservable) {
    return sharedA11YObservable;
  }

  sharedA11YObservable = new Observable() as SharedA11YObservable;

  sharedA11YObservable.set(AccessibilityServiceEnabledPropName, isAccessibilityServiceEnabled());

  if (typeof UIAccessibilityVoiceOverStatusDidChangeNotification !== 'undefined') {
    nativeObserver = nsApp.ios.addNotificationObserver(UIAccessibilityVoiceOverStatusDidChangeNotification, () =>
      sharedA11YObservable.set(AccessibilityServiceEnabledPropName, isAccessibilityServiceEnabled()),
    );

    nsApp.on(nsApp.exitEvent, () => {
      if (nativeObserver) {
        nsApp.ios.removeNotificationObserver(nativeObserver, UIAccessibilityVoiceOverStatusDidChangeNotification);
      }

      nativeObserver = null;
      sharedA11YObservable = null;
    });
  } else if (typeof UIAccessibilityVoiceOverStatusChanged !== 'undefined') {
    nativeObserver = nsApp.ios.addNotificationObserver(UIAccessibilityVoiceOverStatusChanged, () =>
      sharedA11YObservable.set(AccessibilityServiceEnabledPropName, isAccessibilityServiceEnabled()),
    );

    nsApp.on(nsApp.exitEvent, () => {
      if (nativeObserver) {
        nsApp.ios.removeNotificationObserver(nativeObserver, UIAccessibilityVoiceOverStatusChanged);
      }