當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript observable.fromObject函數代碼示例

本文整理匯總了TypeScript中tns-core-modules/data/observable.fromObject函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript fromObject函數的具體用法?TypeScript fromObject怎麽用?TypeScript fromObject使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了fromObject函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1:

            onDiscovered: (peripheral: any) => {
                // peripherals.push(observable.fromObject(peripheral));
                console.log('peripheral', JSON.stringify(peripheral));
                this.peripherals.push(observable.fromObject(peripheral));

                console.log('Size: ', this.peripherals.length);
            }
開發者ID:SmartTraceIO,項目名稱:smarttrace-beacon,代碼行數:7,代碼來源:bluetooth.component.ts

示例2: onLoaded

export function onLoaded(args) {
    const page = args.object;
    page.bindingContext = fromObject({
        items: [
            { id: 1, name: "Ter Stegen", role: "Goalkeeper" },
            { id: 3, name: "Piqué", role: "Defender" },
            { id: 4, name: "I. Rakitic", role: "Midfielder" },
            { id: 5, name: "Sergio", role: "Midfielder" },
            { id: 6, name: "Denis Suárez", role: "Midfielder\nSecond line for the sake of testing" },
            { id: 7, name: "Arda", role: "Midfielder" },
            { id: 8, name: "A. Iniesta", role: "Midfielder" },
            { id: 9, name: "Suárez", role: "Forward" },
            { id: 10, name: "Messi", role: "Forward" },
            { id: 11, name: "Neymar", role: "Forward\nSecond line for the sake of testing" },
            { id: 12, name: "Rafinha", role: "Midfielder\nSecond line for the sake of testing" },
            { id: 13, name: "Cillessen", role: "Goalkeeper\nSecond line for the sake of testing" },
            { id: 14, name: "Mascherano", role: "Defender" },
            { id: 17, name: "Paco Alcácer", role: "Forward" },
            { id: 18, name: "Jordi Alba", role: "Defender\nSecond line for the sake of testing" },
            { id: 19, name: "Digne", role: "Defender" },
            { id: 20, name: "Sergi Roberto", role: "Midfielder\nSecond line for the sake of testing" },
            { id: 21, name: "André Gomes", role: "Midfielder\nSecond line for the sake of testing" },
            { id: 22, name: "Aleix Vidal", role: "Midfielder" },
            { id: 23, name: "Umtiti", role: "Defender" },
            { id: 24, name: "Mathieu", role: "Defender" },
            { id: 25, name: "Masip", role: "Goalkeeper" },
        ]
    });
}
開發者ID:NathanWalker,項目名稱:NativeScript,代碼行數:29,代碼來源:issue-ng-repo-1626.ts

示例3: loaded

export function loaded(args) {
    var items = [];

    for (let i = 0; i < 100; i++) {
        items.push(fromObject({
            text:  "<" + i + ">",
            selected: !!!(i % 5)
        }));
    }
    args.object.bindingContext = { items: items };
}
開發者ID:NathanWalker,項目名稱:NativeScript,代碼行數:11,代碼來源:item-re-layout.ts

示例4: onLoaded

export function onLoaded(args) {
    console.log("back-button modal test loaded");
    context = fromObject({
        message: "First back-press will be canceled",
        shouldCancel: true
    });

    args.object.bindingContext = context;

    if (androidApp) {
        androidApp.on("activityBackPressed", activityBackPressedCallback);
    }
}
開發者ID:NathanWalker,項目名稱:NativeScript,代碼行數:13,代碼來源:android-back-button-page.ts

示例5: fromObject

import {fromObject} from 'tns-core-modules/data/observable';
import {isIOS} from 'platform';
import {Font} from 'ui/styling/font';

const model = fromObject({
    isDisabled: false,
    title: '',
    demoText: '',
    errorMsg: null,
    hint: 'Default Demo Hint',
    isErrorEnabled: true,
    isHintAnimationEnabled: true,
    isCounterEnabled: true,
    iconFont: Font.default.withFontFamily("FontAwesome").withFontSize(16).getUIFont(null),
    iconText: '\uf06a'
});
export default model;
開發者ID:bradleygore,項目名稱:nativescript-textinputlayout,代碼行數:17,代碼來源:main-view-model.ts

示例6: pageLoaded

import { ObservableArray } from "tns-core-modules/data/observable-array";
import { Color } from "color";
import { PullToRefresh } from "nativescript-pulltorefresh";

const users = [
  { name: "Billy Bob" },
  { name: "Tweeder" },
  { name: "Mox" },
  { name: "Coach" },
  { name: "Lance" },
  { name: "Johnson" },
  { name: "William" },
  { name: "Franklin" }
];
const viewModel = observableModule.fromObject({
  users: new ObservableArray(users)
});

function pageLoaded(args) {
  const page = args.object;
  // Change statusbar color on Lollipop

  if (app.android && platformModule.device.sdkVersion >= "21") {
    const window = app.android.startActivity.getWindow();
    window.setStatusBarColor(new Color("#1976D2").android);
  }
  page.bindingContext = viewModel;
  loadItems();
}
exports.pageLoaded = pageLoaded;
開發者ID:PeterStaev,項目名稱:nativescript-pulltorefresh,代碼行數:30,代碼來源:main-page.ts

示例7: initNativeView

 public initNativeView() {
     super.initNativeView();
     const ref = new WeakRef(this);
     let that = this;
     const listener = (co as any).fitcom.fancycamera.CameraEventListenerUI.extend(
         {
             onVideoEventUI(event: co.fitcom.fancycamera.VideoEvent) {
                 const owner = ref.get();
                 if (
                     event.getType() === co.fitcom.fancycamera.EventType.INFO &&
                     event
                         .getMessage()
                         .indexOf(
                             co.fitcom.fancycamera.VideoEvent.EventInfo.RECORDING_FINISHED.toString()
                         ) > -1
                 ) {
                     if (that.thumbnailCount && that.thumbnailCount > 0) {
                         that.extractThumbnails(event.getFile().getPath());
                     }
                     owner.notify({
                         eventName: 'finished',
                         object: fromObject({
                             file: event.getFile().getPath()
                         })
                     });
                 } else if (
                     event.getType() === co.fitcom.fancycamera.EventType.INFO &&
                     event
                         .getMessage()
                         .indexOf(
                             co.fitcom.fancycamera.VideoEvent.EventInfo.RECORDING_STARTED.toString()
                         ) > -1
                 ) {
                     owner.notify({
                         eventName: 'started',
                         object: fromObject({})
                     });
                 } else {
                     if (event.getType() === co.fitcom.fancycamera.EventType.ERROR) {
                         owner.notify({
                             eventName: 'error',
                             object: fromObject({
                                 message: event.getMessage()
                             })
                         });
                     } else {
                         owner.notify({
                             eventName: 'info',
                             object: fromObject({
                                 message: event.getMessage()
                             })
                         });
                     }
                 }
             },
             onPhotoEventUI(event: co.fitcom.fancycamera.PhotoEvent) {
             }
         }
     );
     this.nativeView.setListener(new listener());
     this.setQuality(this.quality);
     this.setCameraPosition(this.cameraPosition);
 }
開發者ID:triniwiz,項目名稱:nativescript-videorecorder,代碼行數:63,代碼來源:advanced-video-view.android.ts

示例8: fromObject

import { fromObject } from 'tns-core-modules/data/observable';
import { SocketIO } from 'nativescript-socketio';
import { isAndroid } from 'tns-core-modules/platform/platform';
import { topmost } from 'tns-core-modules/ui/frame';
import * as moment from 'moment';
import * as application from 'tns-core-modules/application';
let socketIO: SocketIO, pageData = fromObject({
    item: '',
    username: 'Osei'
});

const server = isAndroid ? 'http://10.0.2.2:3001?test=123&platform=android' : 'http://localhost:3001?test=123&platform=ios';

let chatNS;

const resources = application.getResources();
resources['timeFromNow'] = (date) => moment(date).fromNow();

application.setResources(resources);


export function pageLoaded(args) {

    socketIO = new SocketIO(server, {});

    socketIO.on('login', function (data) {
        console.log('Login');
        console.dir(data);
        topmost().navigate({
            moduleName: 'main-page',
            context: {username: pageData.get('username'), socket: socketIO.instance}
開發者ID:triniwiz,項目名稱:nativescript-socketio,代碼行數:31,代碼來源:login-page.ts


注:本文中的tns-core-modules/data/observable.fromObject函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。