当前位置: 首页>>代码示例>>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;未经允许,请勿转载。