Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
});
}
public videoViewDidReceiveData(view: any) {
console.log('videoViewDidReceiveData');
this._event.notify({
eventName: 'videoViewDidReceiveData',
object: fromObject({
view: view,
})
});
}
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);
}
) {
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' })
});
}
}
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"
setInterval(() => {
if (this.items.length < 500) {
this.items.push(fromObject(items[Math.floor(Math.random() * items.length)]));
}
}, 10);
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);
});
function CarDetailViewModel(carModel) {
const viewModel = observableModule.fromObject({
car: carModel
});
return viewModel;
}
onError(reason: string) {
this._event.notify({
eventName: 'error',
object: fromObject({
reason: reason
})
});
}
notify(reason: string) {
this.event.notify({
eventName: 'error',
object: fromObject({
reason: reason
})
});
}