How to use the tns-core-modules/data/observable.fromObject function in tns-core-modules

To help you get started, we’ve selected a few tns-core-modules 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 NativeScript / nativescript-app-templates / packages / template-enterprise-auth / app / login / login-view-model.js View on Github external
function LoginViewModel() {
    const viewModel = observableModule.fromObject({

        login: function () {
            var that = this;
            var activeUser = Kinvey.User.getActiveUser();
            if (activeUser == null) {
                Kinvey.User.loginWithMIC()
                    .then(function (user) {
                        activeUser = user;
                        that._navigateHome(activeUser);
                        console.log("user: " + JSON.stringify(user));
                    })
                    .catch(function (error) {
                        alert("An error occurred. Check your Kinvey settings.");
                        console.log("error: " + error);
                    });
            }
github armackey / nativescript-twilio-video / src / ios / delegates.ts View on Github external
public videoViewDidReceiveData(view: any) {
        console.log('videoViewDidReceiveData');
        this._event.notify({
            eventName: 'videoViewDidReceiveData',
            object: fromObject({
                view: view,
            })
        });
    }
github triniwiz / nativescript-accordion / src / android / accordion.ts View on Github external
getGroupView(groupPosition: number, isExpanded: boolean, convertView: android.view.View, parent: android.view.ViewGroup) {
        let owner = this.owner;
        //View Cache fix
        /*if (convertView) {
            convertView = owner._headerMap.get(groupPosition) ? owner._headerMap.get(groupPosition)._nativeView : null;
            if (convertView) {
                return convertView;
            }

        }*/
        let view: any = !types.isNullOrUndefined(owner.headerTemplate) ? parse(owner.headerTemplate, this) : null;
        let _args = notifyForHeaderOrFooterAtIndex(owner, view ? view.nativeView : null, view, HEADERLOADING, groupPosition);
        view = view || _args.view;
        if (view) {
            const data = owner._getParentData(groupPosition);
            view.bindingContext = fromObject(data);
            if (!view.parent) {
                owner._addView(view);
            }
            owner._headerMap.set(groupPosition, view);
            return view.nativeView;
        }
        const header = new Label();
        header.text = owner._getParentData(groupPosition) ? owner._getParentData(groupPosition).headerText : "";
        if (owner.headerTextAlignment === "center") {
            header.nativeView.setTextAlignment(android.view.View.TEXT_ALIGNMENT_CENTER);
        } else if (owner.headerTextAlignment === "right") {
            header.android.setTextAlignment(android.view.View.TEXT_ALIGNMENT_VIEW_END);
        } else if (owner.headerTextAlignment === "left") {
            header.nativeView.setTextAlignment(android.view.View.TEXT_ALIGNMENT_VIEW_START);
        }
github TeamHive / nativescript-pspdfkit / src / ios / pspdfkit.ts View on Github external
) {
            let controller = PSPDFViewController.new();
            controller.document = getDocument(filePath.path);
            topmost().ios.controller.initWithRootViewController(controller);
            this.events.notify({
              eventName: 'status',
              object: fromObject({ value: 'completed' })
            });
          }
        }
      }
    );
    this._downloadTask.resume();
    this.events.notify({
      eventName: 'status',
      object: fromObject({ value: 'downloading' })
    });
  }
}
github NativeScript / nativescript-app-templates / packages / template-tab-navigation / app / home / home-items-view-model.js View on Github external
function HomeItemsViewModel() {
    const viewModel = observableModule.fromObject({
        items: [
            {
                name: "Item 1",
                description: "Description for Item 1"
            },
            {
                name: "Item 2",
                description: "Description for Item 2"
            },
            {
                name: "Item 3",
                description: "Description for Item 3"
            },
            {
                name: "Item 4",
                description: "Description for Item 4"
github ProximaTeam / nativescript-card-stack-view / demo-ng / app / item / items.component.ts View on Github external
setInterval(() => {

      if (this.items.length < 500) {
        this.items.push(fromObject(items[Math.floor(Math.random() * items.length)]));
      }

    }, 10);
github NativeScript / nativescript-app-templates / packages / template-master-detail-kinvey / app / cars / cars-list-view-model.js View on Github external
function CarsListViewModel() {
    const viewModel = observableModule.fromObject({
        cars: new ObservableArray([]),
        isLoading: false,

        _carService: CarService.getInstance(),

        load: function () {
            this.set("isLoading", true);

            this._carService.load()
                .then((cars) => {
                    this.set("cars", new ObservableArray(cars));
                    this.set("isLoading", false);
                })
                .catch(() => {
                    this.set("isLoading", false);
                });
github NativeScript / nativescript-app-templates / packages / template-master-detail-kinvey / app / cars / car-detail-page / car-detail-view-model.js View on Github external
function CarDetailViewModel(carModel) {
    const viewModel = observableModule.fromObject({
        car: carModel
    });

    return viewModel;
}
github armackey / nativescript-twilio-video / src / android / twilio-video.ts View on Github external
onError(reason: string) {
        this._event.notify({
            eventName: 'error',
            object: fromObject({
                reason: reason
            })
        });
    }
github armackey / nativescript-twilio-video / src / ios / twilio-video.ts View on Github external
notify(reason: string) {

        this.event.notify({
            eventName: 'error',
            object: fromObject({
                reason: reason
            })
        });

    }