本文整理汇总了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);
}
示例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" },
]
});
}
示例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 };
}
示例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);
}
}
示例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;
示例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;
示例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);
}
示例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}