The document discusses the mobile backend platform Parse and its features. Parse provides a complete backend for mobile and web applications, allowing developers to store and query data, implement user authentication and authorization, and more. It supports numerous platforms including Android, iOS, JavaScript, and embedded devices. Some key features covered include object modeling and storage, queries, user management, file storage, and security configuration via access control lists.
Parse is a suite of cloud based APIs, services and libraries that focus on letting developers build out rich applications and less time dealing with the overhead of setting up and managing databases, push notifications, social sign on, analytics, and even hosting and servers.
In this series I'll overview the options around developing an application that leverages Parse, including using Cloud Code to deploy your Node.js app to Parse's own hosting service.
This document provides an overview of the Parse platform and its capabilities for building mobile and web applications. It describes Parse Core which allows storing and querying data in the cloud. It also covers user authentication, social integration, push notifications, cloud code, and analytics tracking. The document shows how to perform common tasks like saving and querying objects, user signup/login, and sending push notifications. It emphasizes that Parse provides a full backend as a service to focus on app business logic and UI rather than operations.
The document discusses using Parse Cloud Code to build web applications, including basic operations like create, read, update, delete, how Parse and RESTful APIs work, and how to use Cloud Code to call external APIs, run background jobs, and include other JavaScript modules.
Parse: A Mobile Backend as a Service (MBaaS)Ville Seppänen
Parse is a mobile backend as a service (MBaaS), a subcategory of PaaS. This is a presentation evaluating the service for a post-graduate seminar course.
BaaS is a model for providing app developers with backend cloud storage and APIs while also providing features like user management, push notifications, and social integration. Parse is a popular BaaS platform that allows developers to store and query data, implement user authentication and authorization, and send push notifications, all through a simple open source SDK. The Parse SDK allows saving, retrieving, updating, and deleting objects from the cloud and includes support for features like files, users, queries, and local data storage.
This document introduces the Database.com SDK for building Java applications that interact with Salesforce data. It discusses the key components of the SDK including the JPA provider, API connector, and OAuth authentication. It also provides an overview of how to deploy Java applications to Heroku, including using Git for deployment, configuring dynos, and other Heroku features.
[AngularJS] From Angular to Mobile in 30 minutesGlobant
AngularJS is a toolset for building web application frameworks. It allows developers to create controllers and views, bind data to HTML, and communicate with servers. The document discusses AngularJS concepts like $scope, controllers, dependency injection and shows an example of building a TODO list app with AngularJS. Key features highlighted include data binding, directives, forms, localization and more.
This document describes a framework for building and launching micro-apps using Node.js, Electron, and Cordova. It discusses using Node.js to build single-page apps and a server, and leveraging Electron and Cordova to deploy the apps as desktop and mobile applications respectively. Code samples are provided for configuring, building, and launching multiple micro-apps from a single application window on different platforms.
This document summarizes Paco de la Cruz's presentation on Azure Durable Functions. The presentation covered the evolution of application platforms from on-premises to serverless. It then discussed Azure Functions and some challenges it faces with stateful orchestrations. Durable Functions were introduced as an extension of Azure Functions that uses a Durable Task Framework to implement stateful workflows in a serverless manner. Key patterns demonstrated include function chaining, fan-out/fan-in, and using an orchestration client to start and monitor orchestrations. Code samples and demos were provided to illustrate approval workflows using Durable Functions.
Async/await is a new language feature that will ship with Swift 5.5 this year. There’s no doubt it will have a significant impact on how we write asynchronous code.
In this talk, we’re going to look at some use cases for async/await, how we can call existing Swift APIs using this new feature, and why your decision to write your SDK in Objective-C might turn out to have been a very clever move.
We’ll also have a look at the refactoring support Apple is adding to Xcode and how it will help you migrate your existing code base.
This document provides an overview of Durable Functions, which allow for implementing stateful workflows in Azure Functions. Durable Functions enable writing stateful workflows as code by using orchestrator functions to coordinate asynchronous activity functions. Key components include orchestrator functions that call and coordinate stateless activity functions, and an orchestration client to start and manage orchestrations. Patterns demonstrated include function chaining, fan-out/fan-in, and using an orchestration client to start and monitor orchestrations.
The document provides information about Realm, a mobile database solution that serves as an alternative to SQLite and Core Data. It summarizes key features of Realm such as being very fast, using object modeling similar to an ORM, automatically refreshing query results, supporting encryption and multiple databases, and providing documentation in Korean. An example use case of Realm in an Instagram photo browsing app called InstagRealm is also described, showing how Realm is used to store and query Instagram API data and update the UI in response to new items.
This document provides examples and documentation on Azure Durable Functions patterns and concepts. It includes examples of orchestrator and activity functions, orchestration triggers, and common patterns like function chaining, fan-out/fan-in, and asynchronous HTTP responses. It also covers durable function concepts such as the control queue, work item queue, and history table.
The document describes Johannes Brodwall's philosophy of "bare-knuckle web development" which advocates for lightweight frameworks, test-driven development, and avoiding unnecessary complexity. It then demonstrates this approach through building a simple phonebook web application in Java using only the bare essentials like servlets and XML parsing. Finally, it discusses further directions this approach could be taken, such as building applications for the Norwegian agricultural authority and power grid operator.
The document discusses setting up a Lambda function and AWS IoT rule to handle disconnection events from an IoT device using MQTT's Last Will and Testament (LWT) feature. When the device connection terminates unexpectedly, LWT will publish a disconnect message to a topic that triggers the Lambda function. The function logs the disconnect event. The code example modifies the device client to define an LWT message payload and topic so it can notify of disconnections.
Firebase and ng2
This document discusses Firebase and AngularFire/AngularFire2. It summarizes that Firebase is a backend as a service that provides realtime database functionality. AngularFire/AngularFire2 are wrappers that make the Firebase API accessible to Angular applications. Key features covered include authentication, authorization, data validation, and working with data through observable references and promises. Best practices like shallow data structures and avoiding deep nesting are also highlighted.
This document describes setting up a system to capture IoT data streams using both AWS IoT and Kinesis. Rules are configured to activate a Direct-To-Kinesis stream during certain events to capture real-time data. Lambda functions are created to handle logging, process Kinesis stream data, and publish updates to device shadows to control the streaming state. The code sample connects a device, sends test messages, and demonstrates switching between AWS IoT and Kinesis streaming based on the device shadow state.
The document discusses launching an app called Beeline using Firebase services. It describes setting up user authentication with Firebase Authentication, storing user and destination data in the Firebase Realtime Database using security rules, and writing and testing Cloud Functions to aggregate data and handle events. It also mentions integrating Firebase on Android and iOS apps, testing deployments continuously, and ideas for advanced features like permissions, indexing, analytics automation, and web dashboards. Overall the document provides an overview of how Beeline leveraged various Firebase services to build their mobile app backend.
Most AWS APIs will have limits on the amount of data you can send in one request and sometimes you really need to send a lot of data! To try to maximise the amount of data you can send, while still staying within the limits, some APIs support sending gzip-compressed payloads. But how can you send a gzipped request when using the Python SDK for AWS (boto3)? Well, I needed to answer this question recently and it turned out not to be as easy as I anticipated… Let’s jump into this rabbit hole together and let’s find out the answer!
This document discusses dependency injection and inversion of control patterns. It explains that dependency injection frameworks like Angular and Ember use an inversion of control container to manage dependencies and instantiate classes with their dependencies already satisfied. The container owns and manages all class registrations and dependencies. When a class is looked up from the container, it is instantiated with all its dependencies injected. This decouples classes from their concrete dependencies and makes applications more modular and testable.
This document discusses using Flask and Eve to build a REST API with Python in 3 days. It introduces Flask as a microframework for building web applications with Python. Eve is presented as a Python framework built on Flask that allows building RESTful APIs with MongoDB in a simple way. The document provides examples of creating basic Flask and Eve apps, configuring Eve settings like schemas and authentication, and describes many features of Eve like filtering, sorting, pagination and validation.
This document summarizes Luca Mearelli's presentation on controlling cloud services with Python. It discusses how to connect to and interact with Amazon Web Services like S3, EC2, SQS, and SDB using the Boto Python library. Specific topics covered include creating and managing buckets, keys, and objects in S3; launching, controlling, and securing EC2 instances; sending and receiving messages with SQS queues; and storing and querying structured data in SDB domains with items and attributes.
This presentation covers:
The main components in the connectivity path.
Best practices in your code to avoid connectivity issues.
How to solve most common connectivity problems.
Promises are a popular pattern for asynchronous operations in JavaScript, existing in some form in every client-side framework in widespread use today. We'll give a conceptual and practical intro to promises in general, before moving on to talking about how they fit into Angular. If you've ever wondered what exactly $q was about, this is the place to learn!
This document provides information on building skills for Alexa using APIs and ColdBox frameworks. It discusses setting up Amazon developer accounts and AWS services accounts. It also covers creating Lambda functions in Node.js to call APIs from Alexa skills and building ColdBox REST APIs to interface with Alexa skills. The document includes code snippets for sample Lambda functions and ColdBox handlers to integrate with Alexa skills.
C# 6 introduced several new features to the popular C# language, including null-conditional operators to simplify null checking, the ability to await asynchronous operations in catch and finally blocks, nameof expressions to protect against refactoring bugs, and string interpolation for more readable string formatting. Other additions in C# 6 were auto-property initializers, using static for less verbose access to static members, and collection initializers that allow explicitly setting indexes. While some saw the new features as simply reducing boilerplate code, migrating the compiler to a new platform allowed continued innovation in C#.
This document describes a framework for building and launching micro-apps using Node.js, Electron, and Cordova. It discusses using Node.js to build single-page apps and a server, and leveraging Electron and Cordova to deploy the apps as desktop and mobile applications respectively. Code samples are provided for configuring, building, and launching multiple micro-apps from a single application window on different platforms.
This document summarizes Paco de la Cruz's presentation on Azure Durable Functions. The presentation covered the evolution of application platforms from on-premises to serverless. It then discussed Azure Functions and some challenges it faces with stateful orchestrations. Durable Functions were introduced as an extension of Azure Functions that uses a Durable Task Framework to implement stateful workflows in a serverless manner. Key patterns demonstrated include function chaining, fan-out/fan-in, and using an orchestration client to start and monitor orchestrations. Code samples and demos were provided to illustrate approval workflows using Durable Functions.
Async/await is a new language feature that will ship with Swift 5.5 this year. There’s no doubt it will have a significant impact on how we write asynchronous code.
In this talk, we’re going to look at some use cases for async/await, how we can call existing Swift APIs using this new feature, and why your decision to write your SDK in Objective-C might turn out to have been a very clever move.
We’ll also have a look at the refactoring support Apple is adding to Xcode and how it will help you migrate your existing code base.
This document provides an overview of Durable Functions, which allow for implementing stateful workflows in Azure Functions. Durable Functions enable writing stateful workflows as code by using orchestrator functions to coordinate asynchronous activity functions. Key components include orchestrator functions that call and coordinate stateless activity functions, and an orchestration client to start and manage orchestrations. Patterns demonstrated include function chaining, fan-out/fan-in, and using an orchestration client to start and monitor orchestrations.
The document provides information about Realm, a mobile database solution that serves as an alternative to SQLite and Core Data. It summarizes key features of Realm such as being very fast, using object modeling similar to an ORM, automatically refreshing query results, supporting encryption and multiple databases, and providing documentation in Korean. An example use case of Realm in an Instagram photo browsing app called InstagRealm is also described, showing how Realm is used to store and query Instagram API data and update the UI in response to new items.
This document provides examples and documentation on Azure Durable Functions patterns and concepts. It includes examples of orchestrator and activity functions, orchestration triggers, and common patterns like function chaining, fan-out/fan-in, and asynchronous HTTP responses. It also covers durable function concepts such as the control queue, work item queue, and history table.
The document describes Johannes Brodwall's philosophy of "bare-knuckle web development" which advocates for lightweight frameworks, test-driven development, and avoiding unnecessary complexity. It then demonstrates this approach through building a simple phonebook web application in Java using only the bare essentials like servlets and XML parsing. Finally, it discusses further directions this approach could be taken, such as building applications for the Norwegian agricultural authority and power grid operator.
The document discusses setting up a Lambda function and AWS IoT rule to handle disconnection events from an IoT device using MQTT's Last Will and Testament (LWT) feature. When the device connection terminates unexpectedly, LWT will publish a disconnect message to a topic that triggers the Lambda function. The function logs the disconnect event. The code example modifies the device client to define an LWT message payload and topic so it can notify of disconnections.
Firebase and ng2
This document discusses Firebase and AngularFire/AngularFire2. It summarizes that Firebase is a backend as a service that provides realtime database functionality. AngularFire/AngularFire2 are wrappers that make the Firebase API accessible to Angular applications. Key features covered include authentication, authorization, data validation, and working with data through observable references and promises. Best practices like shallow data structures and avoiding deep nesting are also highlighted.
This document describes setting up a system to capture IoT data streams using both AWS IoT and Kinesis. Rules are configured to activate a Direct-To-Kinesis stream during certain events to capture real-time data. Lambda functions are created to handle logging, process Kinesis stream data, and publish updates to device shadows to control the streaming state. The code sample connects a device, sends test messages, and demonstrates switching between AWS IoT and Kinesis streaming based on the device shadow state.
The document discusses launching an app called Beeline using Firebase services. It describes setting up user authentication with Firebase Authentication, storing user and destination data in the Firebase Realtime Database using security rules, and writing and testing Cloud Functions to aggregate data and handle events. It also mentions integrating Firebase on Android and iOS apps, testing deployments continuously, and ideas for advanced features like permissions, indexing, analytics automation, and web dashboards. Overall the document provides an overview of how Beeline leveraged various Firebase services to build their mobile app backend.
Most AWS APIs will have limits on the amount of data you can send in one request and sometimes you really need to send a lot of data! To try to maximise the amount of data you can send, while still staying within the limits, some APIs support sending gzip-compressed payloads. But how can you send a gzipped request when using the Python SDK for AWS (boto3)? Well, I needed to answer this question recently and it turned out not to be as easy as I anticipated… Let’s jump into this rabbit hole together and let’s find out the answer!
This document discusses dependency injection and inversion of control patterns. It explains that dependency injection frameworks like Angular and Ember use an inversion of control container to manage dependencies and instantiate classes with their dependencies already satisfied. The container owns and manages all class registrations and dependencies. When a class is looked up from the container, it is instantiated with all its dependencies injected. This decouples classes from their concrete dependencies and makes applications more modular and testable.
This document discusses using Flask and Eve to build a REST API with Python in 3 days. It introduces Flask as a microframework for building web applications with Python. Eve is presented as a Python framework built on Flask that allows building RESTful APIs with MongoDB in a simple way. The document provides examples of creating basic Flask and Eve apps, configuring Eve settings like schemas and authentication, and describes many features of Eve like filtering, sorting, pagination and validation.
This document summarizes Luca Mearelli's presentation on controlling cloud services with Python. It discusses how to connect to and interact with Amazon Web Services like S3, EC2, SQS, and SDB using the Boto Python library. Specific topics covered include creating and managing buckets, keys, and objects in S3; launching, controlling, and securing EC2 instances; sending and receiving messages with SQS queues; and storing and querying structured data in SDB domains with items and attributes.
This presentation covers:
The main components in the connectivity path.
Best practices in your code to avoid connectivity issues.
How to solve most common connectivity problems.
Promises are a popular pattern for asynchronous operations in JavaScript, existing in some form in every client-side framework in widespread use today. We'll give a conceptual and practical intro to promises in general, before moving on to talking about how they fit into Angular. If you've ever wondered what exactly $q was about, this is the place to learn!
This document provides information on building skills for Alexa using APIs and ColdBox frameworks. It discusses setting up Amazon developer accounts and AWS services accounts. It also covers creating Lambda functions in Node.js to call APIs from Alexa skills and building ColdBox REST APIs to interface with Alexa skills. The document includes code snippets for sample Lambda functions and ColdBox handlers to integrate with Alexa skills.
C# 6 introduced several new features to the popular C# language, including null-conditional operators to simplify null checking, the ability to await asynchronous operations in catch and finally blocks, nameof expressions to protect against refactoring bugs, and string interpolation for more readable string formatting. Other additions in C# 6 were auto-property initializers, using static for less verbose access to static members, and collection initializers that allow explicitly setting indexes. While some saw the new features as simply reducing boilerplate code, migrating the compiler to a new platform allowed continued innovation in C#.
Fundamental Node.js (Workshop bersama Front-end Developer GITS Indonesia, War...GITS Indonesia
Salah satu front-end developer GITS Indonesia, Warsono, mengisi workshop di universitas, mengenai Vue.js.
Ikuti kami di kanal berikut, agar tidak ketinggalan acara seru:
Instagram: @gitsindonesia
LinkedIn: GITS Indonesia
Website: gits.id
Avoiding callback hell in Node js using promisesAnkit Agarwal
This document discusses using promises in Node.js to avoid callback hell. It explains that Node.js is event-based and non-blocking, allowing it to handle multiple requests simultaneously. However, nested callbacks can result in unwieldy callback pyramids or "callback hell". Promises provide a way to write asynchronous code in a more linear way using method chaining. Key benefits include separation of concerns between wrapping asynchronous functions and controlling flow, as well as more readable code. The document provides examples of chaining, nesting, combining, and creating promises using deferred objects in the Q promise library.
This document provides a case study on using Node.js to build enterprise applications. It discusses how the author's company, ARHS Developments, migrated their testing data from multiple copies of MS Access to a centralized web application called Fatman built with Node.js, Express, MongoDB, and other technologies. Fatman uses Mongoose for object modeling and Async for asynchronous control flow. The document outlines Fatman's architecture and how it handles CRUD operations, schemas, middleware, and controllers to provide a more elegant and scalable solution compared to MS Access.
AngularJS training provides an overview of key AngularJS concepts and best practices for building Angular applications. The document introduces the trainer, Lauri Svan, and discusses AngularJS fundamentals like two-way data binding, dependency injection, templates, controllers and directives. It also outlines the typical structure of an Angular app, including modules, services and routing. Form validation, custom directives and asynchronous validation with ngModelOptions are also covered to demonstrate common Angular patterns and techniques.
This document discusses serverless architectures and provides examples of building serverless applications. It introduces serverless computing and explains why developers want to adopt serverless and DevOps approaches. Examples are given for static and dynamic websites built with serverless technologies like AWS Lambda, API Gateway, and S3 storage. The document also provides a case study of building a serverless application with services like Cognito, DynamoDB, and Lambda. Alternatives to AWS serverless options are mentioned along with takeaways about paying only for resources used.
Is your web app drowning in a sea of JavaScript? Has your client-side codebase grown from "a snippet here and there" to "more JavaScript than HTML"? Do you find yourself writing one-off snippets instead of generalized components? You're not the only one. Learn about a handful of strategies you can use to keep your JavaScript codebase lean, modular, and flexible. We'll cover all the major pain points — MVC, templates, persisting state, namespacing, graceful error handling, client/server communication, and separation of concerns. And we'll cover how to do all this incrementally so that you don't have to redo everything from scratch.
Asynchronous JavaScript development allows long-running operations like network requests or file access to occur without blocking the main thread through an event-driven programming model and callback functions. The browser uses an event loop to queue and execute events. While JavaScript can only execute one task at a time, asynchronous functions expose callbacks to handle completed operations. This can lead to "callback hell" where code becomes nested and difficult to follow. Promises and async/await were introduced to simplify asynchronous code by handling callbacks in a cleaner way similar to synchronous code. Web workers also allow true concurrency by running scripts on a separate thread.
Serverless computing is becoming increasingly popular in cloud native development. It provides advantages to an organization in terms of cost, scalability, and agility. Ballerina was created to make integrations simple. It also adds agility to the development process. What will happen when Ballerina meets serverless? A couple of serverless platforms have already started supporting Ballerina as a runtime.
This presentation will discuss the advantages of adopting a serverless strategy, the work done in running Ballerina in OpenWhisk and Kubeless, and other efforts going on to support Ballerina in the serverless world.
Using the SharePoint Framework as a surface to express yourself through client side solutions is great but at some point in time, you will require that this beauty you built interacts with APIs holding data that lives within the Office 365 environment. In this session, you will learn how to utilize and optimize your calls to SharePoint via its REST APIs, to the Microsoft Graph and to external services that you might find useful to deliver a rich experience in your solution. You will also learn about how to simplify those calls using the Community-Driven library PnP JS Core that aims to save your time (and sanity) by simplifying the access to the SharePoint REST APIs and to the Microsoft Graph. Goodbye URLs, hello intellisense!
This document discusses using CouchDB on Android applications. It provides instructions on adding CouchDB functionality to an Android project using Couchbase Mobile for Android. It also describes how to access a CouchDB instance from an Android device using Futon and the Couchbase Service. The document contains code examples for creating, reading, updating and deleting CouchDB documents from an Android app.
1) Promises are objects that represent the eventual completion (or failure) of an asynchronous operation, rather than using callbacks. They provide a cleaner way to handle asynchronous code than callbacks alone.
2) A promise has three possible states: pending, fulfilled, and rejected. Promises allow multiple handlers to be attached to an asynchronous operation via the .then() method. Handlers will be called even if attached after the promise is settled.
3) Common uses of promises include handling data retrieval from external sources, loading assets, and handling animations. Promises are well-suited for any potentially asynchronous operation.
This document provides an overview of promises and deferred objects. It discusses the history of promises, including early use in 1976 and implementations in Dojo, Node.js, Q.js and Futures.js. The document defines a promise as an object representing a value that is not yet known, and a deferred as representing work that is not yet finished. It outlines the CommonJS Promises/A specification and details the states a promise can be in. The document then examines jQuery's implementation of promises and deferreds and provides examples of how to use deferreds and promises to manage asynchronous code.
Quick and Easy Development with Node.js and Couchbase ServerNic Raboy
Build an API driven Node.js application that uses Couchbase for its NoSQL database and AngularJS for its front-end. Presented by Nic Raboy, Developer Advocate at Couchbase.
This document discusses various approaches for connecting to and interacting with SharePoint data from a SharePoint Framework web part, including using the SharePoint REST APIs, SharePoint Search, Microsoft Graph, custom APIs, and the PnP JS Core library. It provides code samples for retrieving, creating, updating, and deleting list item data from a SharePoint list using these different approaches. It also covers topics like authentication, permissions, and limitations of each approach.
9. Cloud Functions
S Actual API end points on server
S Written in Javascript
S Allows asynchronous response
S Typical cloud function -
Parse.Cloud.define("hello", function(request, response) {
if(request.isError)
response.error("No Hello for you");
else response.success("Hello World");
});
10. Cloud Functions
S Call cloud code APIs using ParseCloud class -
Map<String, Object> params = new HashMap<>();
params.put("isError", true);
ParseCloud.callFunctionInBackground("hello", params, callback);
S Params can be of any data type supported by Parse.
S Response – either data or error, is handled in callback.
S Synchronous version - callFunction
11. Object Triggers
S Enables us to write hooks during object saving and
destroying.
S beforeSave and afterSave are triggered for object.save();
S beforeDelete and afterDelete are triggered for
object.destroy();
Parse.Cloud.afterSave(”ToDoItem", function (request) {
if (request.object.existed() == false) {
request.object.setACL(getDefaultAcl(request.user));
request.object.save();
}
12. Promises
S A value that may not be available yet, but will be resolved
at some point in future.
S Allows us to write asynchronous code in a more
synchronous fashion.
S The only interface requirement of a Promise is having a
function called then, which can be given callbacks to be
called when the promise is fulfilled or has failed.
S Better error handling
14. Promises
S A simple cloud code to save an object
object.save({
success: function(object) {
},
error: function(object, error) {
}
});
S In the new Promise paradigm, that same code would become
object.save().then(
function(object) { //Success
},
function(error) { //Failure
});
16. Promises
S Actually Yes. But the real power of promises is when
multiple of them are chained together.
S Calling promise.then(func) returns a new promise, which is not
fulfilled until func has completed.
S If a callback supplied to then returns a new promise, then
the promise returned by then will not be fulfilled until the
promise returned by the callback is fulfilled.
18. Promises
S Log in find an object update it
Parse.User.logIn("user", "pass", {
success: function(user) {
query.find({
success: function(results) {
results[0].save({ key: value }, {
success: function(result) {
console.log(“YAYY!”);
}
});
}
});
}
});
S All this even without any error handling code!
19. Promises
S Log in find an object update it
Parse.User.logIn("user", "pass").then(function(user) {
return query.find();
}).then(function(results) {
return results[0].save({ key: value });
}).then(function(result) {
// the object was saved.
});
S What about error handling?
20. Promises – Error Handling
S Error handling in every promise
Parse.User.logIn("user", "pass").then(function(user) {
return query.find();
}, function (error) {
console.error("Login Failed: "+error);
}).then(function(results) {
return results[0].save({ key: value });
}, function (error) {
console.error("Query Failed: "+error);
}).then(function(result) {
// the object was saved.
}, function (error) {
console.error("Save Failed: "+error);
});
S Things are getting messy again.
21. Promises – Error Handling
S Collective error handling
Parse.User.logIn("user", "pass").then(function(user) {
return query.find();
}).then(function(results) {
return results[0].save({ key: value });
}).then(function(result) {
// the object was saved.
}, function (error) {
console.error("Operation Failed: "+error);
});
22. Promises – Error Handling
S If a Promise in a chain fails, all of the success callbacks
after it will be skipped until an error callback is
encountered.
S The error callback can transform the error, or it can
handle it by returning a new Promise.
S Parse.Promise.error
S Parse.Promise.as
23. Complex Error Handling
query.find().then(function(students) {
students[0].set("valedictorian", true);
// Force this callback to fail.
return Parse.Promise.error("There was an error.");
}).then(function(valedictorian) {
// Now this will be skipped.
return query.find();
}).then(function(students) {
// This will also be skipped.
return students[1].save({"salutatorian", true});
}, function(error) {
// This error handler WILL be called. error will be "There was an error.".
// Let's handle the error by returning a new promise.
return Parse.Promise.as("Hello!");
}).then(function(hello) {
// Everything is done!
}, function(error) {
// This isn't called because the error was already handled.
});
24. Custom Promises
S All of parse methods returns a promise.
S What if you need to create your own method?
S Parse.Promise class
var promise = new Parse.Promise();
promise.resolve("The good result.");
promise.reject("An error message.");
25. Custom Promises
S setTimeout promisified .. promified -
var delay = function(millis) {
var promise = new Parse.Promise();
setTimeout(function() {
promise.resolve();
}, millis);
return promise;
};
S Usage
delay(100).then(function() {
// This ran after 100ms!
});
26. Background Jobs
S BG jobs are schedulable parse cloud functions.
S Mainly used in operations which run independent of API
calls
S For ex: Payment expiration, Redundant data cleanup, etc
S Created using Parse.Cloud.job
S Schedule is created using Dashboard at parse.com
27. Background Jobs
Parse.Cloud.job("clearHeldSlots", function (request, status) {
Parse.Cloud.useMasterKey();
var d = new Date();
d.setTime(d.getTime() - constants.TRANSACTION_EXPIRY_TIME);
var blockedSlotsQuery = new Parse.Query("BlockedSlot");
blockedSlotsQuery.equalTo("isHoldingForBooking", true);
blockedSlotsQuery.lessThanOrEqualTo("createdAt", d);
blockedSlotsQuery.find().then(function (blockedSlots) {
if (blockedSlots != undefined && blockedSlots != null) {
return Parse.Object.destroyAll(blockedSlots);
}
}).then(function () {
status.success();
}, function (error) {
status.error(“Job Failed!);
})
});
32. Cloud Modules
S Cloud Code supports breaking up JavaScript code into
modules.
S Each module is a separate JS file and all the APIs and
data it wants to expose should be added to exports
variable.
S Use require(“path_to_module.js”) to use that module.
S 3rd party modules available for integration with services.
S Ex: underscore, stripe, mailgun
34. Bolts for Android
S Keep long-running operations off of the UI thread.
S If several inter-dependent operations execute in
background, its hard to coordinate.
S Almost all internal Parse Android SDK APIs use bolts
S continueWithTask and onSuccessTask
S continueWith and onSuccess