SlideShare ist ein Scribd-Unternehmen logo
1 von 11
Downloaden Sie, um offline zu lesen
Integrating Backbone.js app with Data Sync 
In this tutorial, you will learn how to integrate an existing Backbone based application with the Data Sync 
module of the Appear IQ platform. The tutorial is based on a well-established application idea of a simple 
task management application which allows users to create new tasks, mark them as completed and 
remove completed tasks from the list. 
Backbone is built on top of a Model-View-Presenter system, where models can be translated directly into Appear IQ's 
business documents with the help of a custom collection implementation. Let's look at an overview of the integrated 
ecosystem: 
The tutorial consists of six steps: 
1. getting the sample Backbone app - We have a prepared a tutorial app based on Backbone, which you will 
integrate with the AIQ Data Sync module. 
2. initializing the AIQ API - The API generates an event called aiq-ready after it has finished loading. You have 
to wait for this event before loading the data in order to have full access to the API. 
3. defining a collection - Backbone Collections take care of synchronizing application data with external data 
sources. In case of Appear IQ, the collection must translate CRUD operations into DataSync API calls. 
4. making models compatible with AIQ - In order for your model classes to be recognized as Appear IQ's 
business documents, they must be enriched with a document identifier called _id. You can also leverage other AIQ 
properties. 
5. registering listeners - An AIQ-enabled application not only manages business documents locally, but also 
reacts to remote changes in those documents. 
6. running the app on your device - To finish, you will be able to publish the app on your smartphone 
This tutorial assumes that you already have basic knowledge of HTML and JavaScript, as well as Backbone.js framework. If 
you feel that you need to go through the basics, don't hesitate to read external tutorials like this and this. Backbone-related
resources can be found here. Remember to also consult the API documentation in case you get lost or you are not sure 
what the Appear IQ API being used does.does. 
Prerequisites 
In order to follow the tutorial, you will need the following components: 
● AIQ Mobile HTML5 SDK tool, version 1.1.0 or later 
In order to publish your application to your device, you will also need an account on the Appear IQ Mobility Platform. 
Please sign-up to get your credentials. Alternatively, you can also carry on and test the application in a local web browser. 
Step 1: Getting the tutorial app 
We have prepared a simple app based on Backbone in order to illustrate the integration steps with the Appear IQ Data 
Sync module. 
First, you need to download the tutorial app from Github. You will see two folders there: 
● todo - vanilla Backbone enabled application which you can use as a base for this tutorial 
● todo+aiq - the end result of the tutorial, integrated with AIQ 
The tutorial will take place in the todo folder. However feel free to jump at anytime to the todo+aiq folder to see the 
intended outcome! 
Step 2: Initializing the API 
We have implemented a mock version of the AIQ API for local development and testing. The first step is to add that mock 
implementation to your app, so that you can test it in your local browser. 
You can get the API mock implementation in the boilerplate app generated by the Mobile HTML5 SDK tool. For that, go to a 
temporary directory and run the following command. 
The generate command will generate a boilerplate app, which is traditionally used to create an app from scratch. In 
the present case, you will only be copying the API mock implementation to the existing tutorial app. 
From the boilerplate app, copy the aiq-api.js file located in the aiq folder into an aiq folder in your application root (you 
have to create the aiq folder as well). 
As with every essential resource, you have to reference it in the index.html file in your application root: 
This will immediately start initializing the API modules. To know when they are ready to use, you have to register a listener 
for the event called aiq-ready. In case of this TODO application, you can delay the whole initial require statement that 
kickstarts the launch. In the index.html file, replace the initialization line with the following script: 
Once you implement and initialize the custom collection, it will immediately try to bind to AIQ events, which will fail if the AIQ 
API is not ready. Calling it after the aiq-ready event is triggered will prevent it.
Step 3: Defining a collection 
Now you can move on to building a custom collection, which will synchronize the data with your backend system through 
the AIQ Data Sync. 
Create a file called backbone.aiq-datasync.js in the libs folder (the local storage based collection which the application has 
been using is also located in this folder, in a file called backbone.localStorage.js) and define a basic structure:
This is an empty skeleton of a Backbone collection which delegates CRUD operation calls passed to the well known sync 
method to the private implementations starting with an underscore. You have to go through these methods (read, create, 
update and delete) and implement them so that they operate on the AIQ API. 
The _createHandler method is used to generate callbacks to the AIQ API methods. 
The sync method is a part of the public Collection API and is called every time a CRUD operation is performed on a 
collection. 
Data Sync module of the AIQ API has a method called synchronize, which serves a different purpose than the sync 
method in the custom collection and shouldn't be mistakingly used in a similar context. 
Models in Backbone framework don't carry the information about the names of their types, which your new collection will 
use to call the Data Sync methods. You need to create an artificial binding between the collection and its model by 
introducing a custom type field specified when inheriting from the base DataSyncCollection. The initialize method is a good 
place to enforce this binding: 
As shown in the example above, you can delegate the sync method from the attached model to the sync method 
you implemented in your collection, so that you don't have to implement the same functionality twice.
In order for your new collection to get used instead of the old local storage implementation, 
you have to create a reference to it in the requirejs.config.js file located in the app folder: 
Instead of adding a new entry, you can replace with it the old and now obsolete reference to the local storage 
implementation: 
Once the reference is defined, you can use it as a base for the TODO collection. Open app/collections/todos.js file, replace 
the old dependency to the local storage extension with the new one, to your new DataSyncCollection class. Get rid of the 
localStorage property (it is no longer needed) and be sure to add the type property to the TodoCollection definition. The 
result should look like this:
As explained in the documentation, AIQ enables you to define a set of mock data which you 
can bundle with your app to simulate data sent by your backend system. In short, it helps you develop your mobile app 
without being tied to the backend being ready. For the sake of that tutorial, you will use mock data when working locally in 
your browser. To that end, let's 
define some mock tasks by creating a datasync.json file in the mock-data folder in the application root (you have to create it 
first) and filling it with the following content: 
This will define three TODO documents illustrating what your backend could have sent. 
In order to make use of the created data, you have to implement the read operation of your collection. It is called when you 
initialize the collection. The _read method (as specified in the sync method of your collection) will retrieve the business 
documents from the AIQ container using the aiq.datasync.getDocuments() call. Add the following function before the initialize 
function in libs/backbone.aiq-datasync.js file: 
This function is called from the sync method and receives a correct set of AIQ callbacks as the options argument. 
This function is used both to populate the collection with the data and to retrieve a single model instance. This is why 
we have to distinguish those two cases by checking if it received an identifier in the first argument. 
Let's see how the application looks like. To do so, start the local web server by issuing the following command: 
Now open http://localhost:8000 in your browser. You should immediately see the mock data:
Great! The only difference from the vanilla application is that now it displays a list of tasks loaded from the mock data 
populated through your new collection. When using live data on your smartphone, this list would display the tasks sent by 
your backend. 
The next operations to be implemented in your Backbone collection are create, update and delete. This will allow your app 
to create documents which will be synchronized through AIQ, as well as update and delete them. Add the following 
functions before the initialize function in libs/backbone.aiq-datasync.js file:
Step 4: Making models compatible with AIQ 
The TODO application has only one model, which you can find in the app/models folder. Let's open the todo.js file and 
prepare it for the integration. It needs the following changes to be applied to it: 
● it has to have an _id field, so that the model can be recognized as an AIQ business document 
● the _id field has to be marked as idAttribute, so that Backbone uses it as a primary identifier 
Add the new attribute to app/models/todo.js as shown below: 
BÖRJA HÄR I FRÅN!!!! 
Step 5: Registering listeners 
The last development step is to react to remote changes in the business documents coming from your backend. This 
functionality belongs to the collection as well. Open the libs/backbone.aiq-datasync.js file and add the following method: 
Once again, in order to bind, you have to wait for the aiq-ready event. Once one of these events is triggered, the load 
function will be invoked.
The load function is used as a callback to simplify the code. In real scenarios, you will want to manually wrap 
incoming business documents into model classes, so that the whole store doesn't need to be reloaded, because it 
can cause severe performance problems once your business document collection becomes big. 
Step 6: Run it on your device 
That's it! Your application is integrated with the AIQ API and is ready to use. Let's build the application… 
…and publish it using the AIQ tool: 
You have to be logged in in order to be able to publish the application. Please consult the documentation to learn 
how to do it. 
The command will publish an application in live mode, which means it is configured to consume data sent by your 
backend. Therefore, you won't any data at this stage unless you (or anyone else in your organization) create it. The 
following screenshot has been taken after adding the three todo.model.TODO documents with the same contents as 
defined in step 4 of this tutorial. 
This is how your application looks on a device:
Conclusion 
In this tutorial you have learned how to integrate a Backbone application with the AIQ Data Sync API. If you want to learn 
about more advanced functions like editing documents, using camera or performing direct calls, check-out our other 
Tutorials.

Weitere ähnliche Inhalte

Was ist angesagt?

The New & Improved Confluence Server and Data Center
The New & Improved Confluence Server and Data CenterThe New & Improved Confluence Server and Data Center
The New & Improved Confluence Server and Data CenterAtlassian
 
Advanced designs for reusable lightning components
Advanced designs for reusable lightning componentsAdvanced designs for reusable lightning components
Advanced designs for reusable lightning componentsthomaswaud
 
Rails Plugins - Linux For You, March 2011 Issue
Rails Plugins - Linux For You, March 2011 IssueRails Plugins - Linux For You, March 2011 Issue
Rails Plugins - Linux For You, March 2011 IssueSagar Arlekar
 
Android Intermediatte IAK full
Android Intermediatte IAK fullAndroid Intermediatte IAK full
Android Intermediatte IAK fullAhmad Arif Faizin
 
Integrating consumers IoT devices into Business Workflow
Integrating consumers IoT devices into Business WorkflowIntegrating consumers IoT devices into Business Workflow
Integrating consumers IoT devices into Business WorkflowYakov Fain
 
The Best Way to Become an Android Developer Expert with Android Jetpack
The Best Way to Become an Android Developer Expert  with Android JetpackThe Best Way to Become an Android Developer Expert  with Android Jetpack
The Best Way to Become an Android Developer Expert with Android JetpackAhmad Arif Faizin
 
From AUI to Atlaskit - Streamlining Development for Server & Cloud Apps
From AUI to Atlaskit - Streamlining Development for Server & Cloud AppsFrom AUI to Atlaskit - Streamlining Development for Server & Cloud Apps
From AUI to Atlaskit - Streamlining Development for Server & Cloud AppsAtlassian
 
Salesforce Lightning Components Workshop
Salesforce Lightning Components WorkshopSalesforce Lightning Components Workshop
Salesforce Lightning Components WorkshopChristophe Coenraets
 
Rails 5 – most effective features for apps upgradation
Rails 5 – most effective features for apps upgradationRails 5 – most effective features for apps upgradation
Rails 5 – most effective features for apps upgradationAndolasoft Inc
 
What's New in Jira Cloud for Developers
What's New in Jira Cloud for DevelopersWhat's New in Jira Cloud for Developers
What's New in Jira Cloud for DevelopersAtlassian
 
Forge: Under the Hood
Forge: Under the HoodForge: Under the Hood
Forge: Under the HoodAtlassian
 
Internet of things the salesforce lego machine cloud
Internet of things   the salesforce lego machine cloudInternet of things   the salesforce lego machine cloud
Internet of things the salesforce lego machine cloudandyinthecloud
 
Integrating Jira Software Cloud With the AWS Code Suite
Integrating Jira Software Cloud With the AWS Code SuiteIntegrating Jira Software Cloud With the AWS Code Suite
Integrating Jira Software Cloud With the AWS Code SuiteAtlassian
 
Integrate CI/CD Pipelines with Jira Software Cloud
Integrate CI/CD Pipelines with Jira Software CloudIntegrate CI/CD Pipelines with Jira Software Cloud
Integrate CI/CD Pipelines with Jira Software CloudAtlassian
 
Discover the Possibilities of the Jira Cloud Asset API
Discover the Possibilities of the Jira Cloud Asset APIDiscover the Possibilities of the Jira Cloud Asset API
Discover the Possibilities of the Jira Cloud Asset APIAtlassian
 
11 asp.net session16
11 asp.net session1611 asp.net session16
11 asp.net session16Vivek chan
 
Integrating SharePoint 2010 and Visual Studio Lightswitch
Integrating SharePoint 2010 and Visual Studio LightswitchIntegrating SharePoint 2010 and Visual Studio Lightswitch
Integrating SharePoint 2010 and Visual Studio LightswitchRob Windsor
 

Was ist angesagt? (20)

Lightning Components Workshop v2
Lightning Components Workshop v2Lightning Components Workshop v2
Lightning Components Workshop v2
 
The New & Improved Confluence Server and Data Center
The New & Improved Confluence Server and Data CenterThe New & Improved Confluence Server and Data Center
The New & Improved Confluence Server and Data Center
 
Advanced designs for reusable lightning components
Advanced designs for reusable lightning componentsAdvanced designs for reusable lightning components
Advanced designs for reusable lightning components
 
Rails Plugins - Linux For You, March 2011 Issue
Rails Plugins - Linux For You, March 2011 IssueRails Plugins - Linux For You, March 2011 Issue
Rails Plugins - Linux For You, March 2011 Issue
 
Android Intermediatte IAK full
Android Intermediatte IAK fullAndroid Intermediatte IAK full
Android Intermediatte IAK full
 
Integrating consumers IoT devices into Business Workflow
Integrating consumers IoT devices into Business WorkflowIntegrating consumers IoT devices into Business Workflow
Integrating consumers IoT devices into Business Workflow
 
The Best Way to Become an Android Developer Expert with Android Jetpack
The Best Way to Become an Android Developer Expert  with Android JetpackThe Best Way to Become an Android Developer Expert  with Android Jetpack
The Best Way to Become an Android Developer Expert with Android Jetpack
 
From AUI to Atlaskit - Streamlining Development for Server & Cloud Apps
From AUI to Atlaskit - Streamlining Development for Server & Cloud AppsFrom AUI to Atlaskit - Streamlining Development for Server & Cloud Apps
From AUI to Atlaskit - Streamlining Development for Server & Cloud Apps
 
Salesforce Lightning Components Workshop
Salesforce Lightning Components WorkshopSalesforce Lightning Components Workshop
Salesforce Lightning Components Workshop
 
Rails 5 – most effective features for apps upgradation
Rails 5 – most effective features for apps upgradationRails 5 – most effective features for apps upgradation
Rails 5 – most effective features for apps upgradation
 
What's New in Jira Cloud for Developers
What's New in Jira Cloud for DevelopersWhat's New in Jira Cloud for Developers
What's New in Jira Cloud for Developers
 
Forge: Under the Hood
Forge: Under the HoodForge: Under the Hood
Forge: Under the Hood
 
Introduction to Google App Engine
Introduction to Google App EngineIntroduction to Google App Engine
Introduction to Google App Engine
 
Internet of things the salesforce lego machine cloud
Internet of things   the salesforce lego machine cloudInternet of things   the salesforce lego machine cloud
Internet of things the salesforce lego machine cloud
 
Integrating Jira Software Cloud With the AWS Code Suite
Integrating Jira Software Cloud With the AWS Code SuiteIntegrating Jira Software Cloud With the AWS Code Suite
Integrating Jira Software Cloud With the AWS Code Suite
 
Integrate CI/CD Pipelines with Jira Software Cloud
Integrate CI/CD Pipelines with Jira Software CloudIntegrate CI/CD Pipelines with Jira Software Cloud
Integrate CI/CD Pipelines with Jira Software Cloud
 
Discover the Possibilities of the Jira Cloud Asset API
Discover the Possibilities of the Jira Cloud Asset APIDiscover the Possibilities of the Jira Cloud Asset API
Discover the Possibilities of the Jira Cloud Asset API
 
11 asp.net session16
11 asp.net session1611 asp.net session16
11 asp.net session16
 
Integrating SharePoint 2010 and Visual Studio Lightswitch
Integrating SharePoint 2010 and Visual Studio LightswitchIntegrating SharePoint 2010 and Visual Studio Lightswitch
Integrating SharePoint 2010 and Visual Studio Lightswitch
 
Android dev tips
Android dev tipsAndroid dev tips
Android dev tips
 

Ähnlich wie Appear IQ - Tutorials Backbone.js

How to build integrated, professional enterprise-grade cross-platform mobile ...
How to build integrated, professional enterprise-grade cross-platform mobile ...How to build integrated, professional enterprise-grade cross-platform mobile ...
How to build integrated, professional enterprise-grade cross-platform mobile ...Appear
 
Appcelerator Titanium Alloy + Kinvey Collection Databinding - Part One
Appcelerator Titanium Alloy + Kinvey Collection Databinding - Part OneAppcelerator Titanium Alloy + Kinvey Collection Databinding - Part One
Appcelerator Titanium Alloy + Kinvey Collection Databinding - Part OneAaron Saunders
 
3 Ways to Get Started with a React App in 2024.pdf
3 Ways to Get Started with a React App in 2024.pdf3 Ways to Get Started with a React App in 2024.pdf
3 Ways to Get Started with a React App in 2024.pdfBOSC Tech Labs
 
Enterprise Level Application Architecture with Web APIs using Entity Framewor...
Enterprise Level Application Architecture with Web APIs using Entity Framewor...Enterprise Level Application Architecture with Web APIs using Entity Framewor...
Enterprise Level Application Architecture with Web APIs using Entity Framewor...Akhil Mittal
 
Creating web api and consuming- part 1
Creating web api and consuming- part 1Creating web api and consuming- part 1
Creating web api and consuming- part 1Dipendra Shekhawat
 
How create react app help in creating a new react applications
How create react app help in creating a new react applications How create react app help in creating a new react applications
How create react app help in creating a new react applications Concetto Labs
 
An Empirical Performance Study of AppEngine and AppScale
An Empirical Performance Study of AppEngine and AppScaleAn Empirical Performance Study of AppEngine and AppScale
An Empirical Performance Study of AppEngine and AppScaleFei Dong
 
Adding User Management to Node.js
Adding User Management to Node.jsAdding User Management to Node.js
Adding User Management to Node.jsDev_Events
 
Aspnet mvc tutorial_01_cs
Aspnet mvc tutorial_01_csAspnet mvc tutorial_01_cs
Aspnet mvc tutorial_01_csAlfa Gama Omega
 
Angular 7 Firebase5 CRUD Operations with Reactive Forms
Angular 7 Firebase5 CRUD Operations with Reactive FormsAngular 7 Firebase5 CRUD Operations with Reactive Forms
Angular 7 Firebase5 CRUD Operations with Reactive FormsDigamber Singh
 
Angular kickstart slideshare
Angular kickstart   slideshareAngular kickstart   slideshare
Angular kickstart slideshareSaleemMalik52
 

Ähnlich wie Appear IQ - Tutorials Backbone.js (20)

Open sap ui5 - week_2 unit_1_syjewa_exercises
Open sap ui5  - week_2 unit_1_syjewa_exercisesOpen sap ui5  - week_2 unit_1_syjewa_exercises
Open sap ui5 - week_2 unit_1_syjewa_exercises
 
How to build integrated, professional enterprise-grade cross-platform mobile ...
How to build integrated, professional enterprise-grade cross-platform mobile ...How to build integrated, professional enterprise-grade cross-platform mobile ...
How to build integrated, professional enterprise-grade cross-platform mobile ...
 
Appcelerator Titanium Alloy + Kinvey Collection Databinding - Part One
Appcelerator Titanium Alloy + Kinvey Collection Databinding - Part OneAppcelerator Titanium Alloy + Kinvey Collection Databinding - Part One
Appcelerator Titanium Alloy + Kinvey Collection Databinding - Part One
 
Flask
FlaskFlask
Flask
 
3 Ways to Get Started with a React App in 2024.pdf
3 Ways to Get Started with a React App in 2024.pdf3 Ways to Get Started with a React App in 2024.pdf
3 Ways to Get Started with a React App in 2024.pdf
 
Oracle jet
Oracle jetOracle jet
Oracle jet
 
Spring User Guide
Spring User GuideSpring User Guide
Spring User Guide
 
Web Os Hands On
Web Os Hands OnWeb Os Hands On
Web Os Hands On
 
Codeigniter
CodeigniterCodeigniter
Codeigniter
 
Google Cloud Platform
Google Cloud Platform Google Cloud Platform
Google Cloud Platform
 
Enterprise Level Application Architecture with Web APIs using Entity Framewor...
Enterprise Level Application Architecture with Web APIs using Entity Framewor...Enterprise Level Application Architecture with Web APIs using Entity Framewor...
Enterprise Level Application Architecture with Web APIs using Entity Framewor...
 
Creating web api and consuming- part 1
Creating web api and consuming- part 1Creating web api and consuming- part 1
Creating web api and consuming- part 1
 
django
djangodjango
django
 
How create react app help in creating a new react applications
How create react app help in creating a new react applications How create react app help in creating a new react applications
How create react app help in creating a new react applications
 
An Empirical Performance Study of AppEngine and AppScale
An Empirical Performance Study of AppEngine and AppScaleAn Empirical Performance Study of AppEngine and AppScale
An Empirical Performance Study of AppEngine and AppScale
 
Adding User Management to Node.js
Adding User Management to Node.jsAdding User Management to Node.js
Adding User Management to Node.js
 
Aspnet mvc tutorial_01_cs
Aspnet mvc tutorial_01_csAspnet mvc tutorial_01_cs
Aspnet mvc tutorial_01_cs
 
Yii php framework_honey
Yii php framework_honeyYii php framework_honey
Yii php framework_honey
 
Angular 7 Firebase5 CRUD Operations with Reactive Forms
Angular 7 Firebase5 CRUD Operations with Reactive FormsAngular 7 Firebase5 CRUD Operations with Reactive Forms
Angular 7 Firebase5 CRUD Operations with Reactive Forms
 
Angular kickstart slideshare
Angular kickstart   slideshareAngular kickstart   slideshare
Angular kickstart slideshare
 

Mehr von Appear

Improving the efficiency of aircraft turnaround
Improving the efficiency of aircraft turnaroundImproving the efficiency of aircraft turnaround
Improving the efficiency of aircraft turnaroundAppear
 
Appear IQ The Business Case for hybrid html5 mobile apps
Appear IQ The Business Case for hybrid html5 mobile appsAppear IQ The Business Case for hybrid html5 mobile apps
Appear IQ The Business Case for hybrid html5 mobile appsAppear
 
White Paper - Securing Mobile Access to enterprise data
White Paper - Securing Mobile Access to enterprise dataWhite Paper - Securing Mobile Access to enterprise data
White Paper - Securing Mobile Access to enterprise dataAppear
 
Appear IQ8 - Mobility. Made Simple. What we do
Appear IQ8 - Mobility. Made Simple. What we doAppear IQ8 - Mobility. Made Simple. What we do
Appear IQ8 - Mobility. Made Simple. What we doAppear
 
Webinar 5 challenges of mobilization april 9 2014
Webinar   5 challenges of mobilization april 9 2014Webinar   5 challenges of mobilization april 9 2014
Webinar 5 challenges of mobilization april 9 2014Appear
 
MobiCloud Transport Webinar Series - Die vernetzten ÖPNV-Mitarbeiter
MobiCloud Transport Webinar Series - Die vernetzten ÖPNV-MitarbeiterMobiCloud Transport Webinar Series - Die vernetzten ÖPNV-Mitarbeiter
MobiCloud Transport Webinar Series - Die vernetzten ÖPNV-MitarbeiterAppear
 
Webinar: Learn how to migrate mobile workers to next generation mobility
Webinar: Learn how to migrate mobile workers to next generation mobilityWebinar: Learn how to migrate mobile workers to next generation mobility
Webinar: Learn how to migrate mobile workers to next generation mobilityAppear
 
Webinar: The Enterrpise Appstore - What is it and why you need it.
Webinar: The Enterrpise Appstore - What is it and why you need it.Webinar: The Enterrpise Appstore - What is it and why you need it.
Webinar: The Enterrpise Appstore - What is it and why you need it.Appear
 
Integrating Mobile Technology in the Construction Industry
Integrating Mobile Technology in the Construction IndustryIntegrating Mobile Technology in the Construction Industry
Integrating Mobile Technology in the Construction IndustryAppear
 
Gartner Catalyst: MobiCloud presentation
Gartner Catalyst: MobiCloud presentationGartner Catalyst: MobiCloud presentation
Gartner Catalyst: MobiCloud presentationAppear
 
MobiCloud Transport Webinar series June 2013 - Dutch
MobiCloud Transport Webinar series June 2013 - DutchMobiCloud Transport Webinar series June 2013 - Dutch
MobiCloud Transport Webinar series June 2013 - DutchAppear
 
MobiCloud Transport Webinar series June 2013 - English
MobiCloud Transport Webinar series June 2013 - English MobiCloud Transport Webinar series June 2013 - English
MobiCloud Transport Webinar series June 2013 - English Appear
 
MobiCloud Transport Webinar series June 2013 - Swedish
MobiCloud Transport Webinar series June 2013 - SwedishMobiCloud Transport Webinar series June 2013 - Swedish
MobiCloud Transport Webinar series June 2013 - SwedishAppear
 

Mehr von Appear (13)

Improving the efficiency of aircraft turnaround
Improving the efficiency of aircraft turnaroundImproving the efficiency of aircraft turnaround
Improving the efficiency of aircraft turnaround
 
Appear IQ The Business Case for hybrid html5 mobile apps
Appear IQ The Business Case for hybrid html5 mobile appsAppear IQ The Business Case for hybrid html5 mobile apps
Appear IQ The Business Case for hybrid html5 mobile apps
 
White Paper - Securing Mobile Access to enterprise data
White Paper - Securing Mobile Access to enterprise dataWhite Paper - Securing Mobile Access to enterprise data
White Paper - Securing Mobile Access to enterprise data
 
Appear IQ8 - Mobility. Made Simple. What we do
Appear IQ8 - Mobility. Made Simple. What we doAppear IQ8 - Mobility. Made Simple. What we do
Appear IQ8 - Mobility. Made Simple. What we do
 
Webinar 5 challenges of mobilization april 9 2014
Webinar   5 challenges of mobilization april 9 2014Webinar   5 challenges of mobilization april 9 2014
Webinar 5 challenges of mobilization april 9 2014
 
MobiCloud Transport Webinar Series - Die vernetzten ÖPNV-Mitarbeiter
MobiCloud Transport Webinar Series - Die vernetzten ÖPNV-MitarbeiterMobiCloud Transport Webinar Series - Die vernetzten ÖPNV-Mitarbeiter
MobiCloud Transport Webinar Series - Die vernetzten ÖPNV-Mitarbeiter
 
Webinar: Learn how to migrate mobile workers to next generation mobility
Webinar: Learn how to migrate mobile workers to next generation mobilityWebinar: Learn how to migrate mobile workers to next generation mobility
Webinar: Learn how to migrate mobile workers to next generation mobility
 
Webinar: The Enterrpise Appstore - What is it and why you need it.
Webinar: The Enterrpise Appstore - What is it and why you need it.Webinar: The Enterrpise Appstore - What is it and why you need it.
Webinar: The Enterrpise Appstore - What is it and why you need it.
 
Integrating Mobile Technology in the Construction Industry
Integrating Mobile Technology in the Construction IndustryIntegrating Mobile Technology in the Construction Industry
Integrating Mobile Technology in the Construction Industry
 
Gartner Catalyst: MobiCloud presentation
Gartner Catalyst: MobiCloud presentationGartner Catalyst: MobiCloud presentation
Gartner Catalyst: MobiCloud presentation
 
MobiCloud Transport Webinar series June 2013 - Dutch
MobiCloud Transport Webinar series June 2013 - DutchMobiCloud Transport Webinar series June 2013 - Dutch
MobiCloud Transport Webinar series June 2013 - Dutch
 
MobiCloud Transport Webinar series June 2013 - English
MobiCloud Transport Webinar series June 2013 - English MobiCloud Transport Webinar series June 2013 - English
MobiCloud Transport Webinar series June 2013 - English
 
MobiCloud Transport Webinar series June 2013 - Swedish
MobiCloud Transport Webinar series June 2013 - SwedishMobiCloud Transport Webinar series June 2013 - Swedish
MobiCloud Transport Webinar series June 2013 - Swedish
 

Kürzlich hochgeladen

Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxRTS corp
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecturerahul_net
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 

Kürzlich hochgeladen (20)

Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecture
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 

Appear IQ - Tutorials Backbone.js

  • 1. Integrating Backbone.js app with Data Sync In this tutorial, you will learn how to integrate an existing Backbone based application with the Data Sync module of the Appear IQ platform. The tutorial is based on a well-established application idea of a simple task management application which allows users to create new tasks, mark them as completed and remove completed tasks from the list. Backbone is built on top of a Model-View-Presenter system, where models can be translated directly into Appear IQ's business documents with the help of a custom collection implementation. Let's look at an overview of the integrated ecosystem: The tutorial consists of six steps: 1. getting the sample Backbone app - We have a prepared a tutorial app based on Backbone, which you will integrate with the AIQ Data Sync module. 2. initializing the AIQ API - The API generates an event called aiq-ready after it has finished loading. You have to wait for this event before loading the data in order to have full access to the API. 3. defining a collection - Backbone Collections take care of synchronizing application data with external data sources. In case of Appear IQ, the collection must translate CRUD operations into DataSync API calls. 4. making models compatible with AIQ - In order for your model classes to be recognized as Appear IQ's business documents, they must be enriched with a document identifier called _id. You can also leverage other AIQ properties. 5. registering listeners - An AIQ-enabled application not only manages business documents locally, but also reacts to remote changes in those documents. 6. running the app on your device - To finish, you will be able to publish the app on your smartphone This tutorial assumes that you already have basic knowledge of HTML and JavaScript, as well as Backbone.js framework. If you feel that you need to go through the basics, don't hesitate to read external tutorials like this and this. Backbone-related
  • 2. resources can be found here. Remember to also consult the API documentation in case you get lost or you are not sure what the Appear IQ API being used does.does. Prerequisites In order to follow the tutorial, you will need the following components: ● AIQ Mobile HTML5 SDK tool, version 1.1.0 or later In order to publish your application to your device, you will also need an account on the Appear IQ Mobility Platform. Please sign-up to get your credentials. Alternatively, you can also carry on and test the application in a local web browser. Step 1: Getting the tutorial app We have prepared a simple app based on Backbone in order to illustrate the integration steps with the Appear IQ Data Sync module. First, you need to download the tutorial app from Github. You will see two folders there: ● todo - vanilla Backbone enabled application which you can use as a base for this tutorial ● todo+aiq - the end result of the tutorial, integrated with AIQ The tutorial will take place in the todo folder. However feel free to jump at anytime to the todo+aiq folder to see the intended outcome! Step 2: Initializing the API We have implemented a mock version of the AIQ API for local development and testing. The first step is to add that mock implementation to your app, so that you can test it in your local browser. You can get the API mock implementation in the boilerplate app generated by the Mobile HTML5 SDK tool. For that, go to a temporary directory and run the following command. The generate command will generate a boilerplate app, which is traditionally used to create an app from scratch. In the present case, you will only be copying the API mock implementation to the existing tutorial app. From the boilerplate app, copy the aiq-api.js file located in the aiq folder into an aiq folder in your application root (you have to create the aiq folder as well). As with every essential resource, you have to reference it in the index.html file in your application root: This will immediately start initializing the API modules. To know when they are ready to use, you have to register a listener for the event called aiq-ready. In case of this TODO application, you can delay the whole initial require statement that kickstarts the launch. In the index.html file, replace the initialization line with the following script: Once you implement and initialize the custom collection, it will immediately try to bind to AIQ events, which will fail if the AIQ API is not ready. Calling it after the aiq-ready event is triggered will prevent it.
  • 3.
  • 4. Step 3: Defining a collection Now you can move on to building a custom collection, which will synchronize the data with your backend system through the AIQ Data Sync. Create a file called backbone.aiq-datasync.js in the libs folder (the local storage based collection which the application has been using is also located in this folder, in a file called backbone.localStorage.js) and define a basic structure:
  • 5. This is an empty skeleton of a Backbone collection which delegates CRUD operation calls passed to the well known sync method to the private implementations starting with an underscore. You have to go through these methods (read, create, update and delete) and implement them so that they operate on the AIQ API. The _createHandler method is used to generate callbacks to the AIQ API methods. The sync method is a part of the public Collection API and is called every time a CRUD operation is performed on a collection. Data Sync module of the AIQ API has a method called synchronize, which serves a different purpose than the sync method in the custom collection and shouldn't be mistakingly used in a similar context. Models in Backbone framework don't carry the information about the names of their types, which your new collection will use to call the Data Sync methods. You need to create an artificial binding between the collection and its model by introducing a custom type field specified when inheriting from the base DataSyncCollection. The initialize method is a good place to enforce this binding: As shown in the example above, you can delegate the sync method from the attached model to the sync method you implemented in your collection, so that you don't have to implement the same functionality twice.
  • 6. In order for your new collection to get used instead of the old local storage implementation, you have to create a reference to it in the requirejs.config.js file located in the app folder: Instead of adding a new entry, you can replace with it the old and now obsolete reference to the local storage implementation: Once the reference is defined, you can use it as a base for the TODO collection. Open app/collections/todos.js file, replace the old dependency to the local storage extension with the new one, to your new DataSyncCollection class. Get rid of the localStorage property (it is no longer needed) and be sure to add the type property to the TodoCollection definition. The result should look like this:
  • 7. As explained in the documentation, AIQ enables you to define a set of mock data which you can bundle with your app to simulate data sent by your backend system. In short, it helps you develop your mobile app without being tied to the backend being ready. For the sake of that tutorial, you will use mock data when working locally in your browser. To that end, let's define some mock tasks by creating a datasync.json file in the mock-data folder in the application root (you have to create it first) and filling it with the following content: This will define three TODO documents illustrating what your backend could have sent. In order to make use of the created data, you have to implement the read operation of your collection. It is called when you initialize the collection. The _read method (as specified in the sync method of your collection) will retrieve the business documents from the AIQ container using the aiq.datasync.getDocuments() call. Add the following function before the initialize function in libs/backbone.aiq-datasync.js file: This function is called from the sync method and receives a correct set of AIQ callbacks as the options argument. This function is used both to populate the collection with the data and to retrieve a single model instance. This is why we have to distinguish those two cases by checking if it received an identifier in the first argument. Let's see how the application looks like. To do so, start the local web server by issuing the following command: Now open http://localhost:8000 in your browser. You should immediately see the mock data:
  • 8. Great! The only difference from the vanilla application is that now it displays a list of tasks loaded from the mock data populated through your new collection. When using live data on your smartphone, this list would display the tasks sent by your backend. The next operations to be implemented in your Backbone collection are create, update and delete. This will allow your app to create documents which will be synchronized through AIQ, as well as update and delete them. Add the following functions before the initialize function in libs/backbone.aiq-datasync.js file:
  • 9. Step 4: Making models compatible with AIQ The TODO application has only one model, which you can find in the app/models folder. Let's open the todo.js file and prepare it for the integration. It needs the following changes to be applied to it: ● it has to have an _id field, so that the model can be recognized as an AIQ business document ● the _id field has to be marked as idAttribute, so that Backbone uses it as a primary identifier Add the new attribute to app/models/todo.js as shown below: BÖRJA HÄR I FRÅN!!!! Step 5: Registering listeners The last development step is to react to remote changes in the business documents coming from your backend. This functionality belongs to the collection as well. Open the libs/backbone.aiq-datasync.js file and add the following method: Once again, in order to bind, you have to wait for the aiq-ready event. Once one of these events is triggered, the load function will be invoked.
  • 10. The load function is used as a callback to simplify the code. In real scenarios, you will want to manually wrap incoming business documents into model classes, so that the whole store doesn't need to be reloaded, because it can cause severe performance problems once your business document collection becomes big. Step 6: Run it on your device That's it! Your application is integrated with the AIQ API and is ready to use. Let's build the application… …and publish it using the AIQ tool: You have to be logged in in order to be able to publish the application. Please consult the documentation to learn how to do it. The command will publish an application in live mode, which means it is configured to consume data sent by your backend. Therefore, you won't any data at this stage unless you (or anyone else in your organization) create it. The following screenshot has been taken after adding the three todo.model.TODO documents with the same contents as defined in step 4 of this tutorial. This is how your application looks on a device:
  • 11. Conclusion In this tutorial you have learned how to integrate a Backbone application with the AIQ Data Sync API. If you want to learn about more advanced functions like editing documents, using camera or performing direct calls, check-out our other Tutorials.