Giter Club home page Giter Club logo

rhoconnect.js's Introduction

RhoConnect.js

A javascript client library for the RhoConnect App Integration Server.

Using rhoconnect.js, your application's model data will transparently synchronize with a mobile application built using the Rhodes framework, or any of the available RhoConnect clients. This client includes built-in support for SenchaTouch data API and Persistence.js models.

Rhoconnect.js is completely UI-agnostic framework, so feel free to use any type of UI javascript library.

Due to to the CORS support in RhoConnect server, you able to create cross-domain applications and standalone mobile applications using PhoneGap framework.

It depends on:

RhoConnect.js actively using deferred/promise objects from jQuery API. All asynchronous results are returned as parameter values of done(..) method call of returned promise object.

Getting started

Load the rhoconnect.js library:

<html>
<head>
    <script type="text/javascript" charset="utf-8" src="external/jquery/jquery-1.6.1.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="external/jquery/jquery.base64.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="external/jquery/json.js"></script>

    <script type="text/javascript">
        RhoConfig = {
            // is used to form the websql database name as <appName>_<login>
            appName: 'rhoPGapSenchaDataSample',
            // RhoConnect application URL
            syncServer: 'http://rhohub-lars-692f63a7.rhosync.com/application'
        };
    </script>

    <script type="text/javascript" charset="utf-8" src="js/rhoconnect-0_9.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="js/your_application.js"></script>
</head>
<body>
</body>
</html>

To use rhoconnect.js you need to login and initialize rhoconnect.js with model definitions this way:

function onSomeClick() {
    loginRhoConnect("someUser", "somePass", false).done(function(){
        // start you business logic here, say..

        var syncInterval = setInterval(function(){

            RhoConnect.syncAllSources().done(function(){
                // updateSomeUI();
            }).fail(function(errCode, err){
                alert('Data sync error: ' +errCode);
                clearInterval(syncInterval);
                syncInterval = null;
            });

        }, 3 * 1000)
    });
}

var modelDefinitions = [
    {
        name: 'Customer',
        fields: [
            {name: 'id',      type: 'int'},
            {name: 'first',   type: 'string'},
            {name: 'last',    type: 'string'},
            {name: 'phone',   type: 'string'},
            {name: 'email',   type: 'string'},
            {name: 'address', type: 'string'},
            {name: 'city',    type: 'string'},
            {name: 'state',   type: 'string'},
            {name: 'zip',     type: 'string'},
            {name: 'lat',     type: 'string'},
            {name: 'long',    type: 'string'}
        ]
    }
];

function loginRhoConnect(username, password, doDataReset) {
    return $.Deferred(function(dfr){

        RhoConnect.login(username, password,
                new RhoConnect.SyncNotification(), doDataReset).done(function(){

            // Init DB for the user on success
            RhoConnect.init(modelDefinitions /*, dataApiType, syncProgressCallback */).done(function(){
                dfr.resolve();
            }).fail(function(errCode, errMessage){
                alert('DB init error: ' +errCode);
                dfr.reject(errCode, errMessage);
            });

            initRhoconnect(username, false).done(function(){
            }).fail(function(errCode, err){
                alert('DB init error: ' +errCode);
                dfr.reject(errCode, err);
            });
        }).fail(function(errCode, err){
            alert('RhoConnect login error: ' +errCode);
            dfr.reject(errCode, err);
        });

    }).promise();
}

You can use RhoConnect.dataAccessObjects() to obtain data API specific objects to access you data. See the API reference.

Meta

Created and maintained by Dmitry Prokhorov.

Released under the MIT License.

rhoconnect.js's People

Contributors

dipspb avatar larsburgess avatar abhineetagarwal avatar

Stargazers

 avatar Rodrigo Martins avatar Dave Sims avatar

Watchers

 avatar Adam Blum avatar  avatar Vladimir Tarasov avatar Evgeny Vovchenko avatar  avatar @mva avatar Dmitry Soldatenkov avatar Konstantin Rybas avatar lucas avatar David Strom avatar Michael Toews avatar James Cloos avatar Darryn avatar  avatar  avatar Rob Galvin avatar  avatar  avatar Paul Henderson avatar  avatar Sunil Kumar avatar Joydeep Chakraborty avatar  avatar Malaya avatar  avatar  avatar  avatar  avatar  avatar  avatar Sharanu Patted avatar  avatar Pavan Banda avatar  avatar  avatar Jayanth G H avatar Rakesh Kumar B Badiger avatar  avatar Ashikh Pai avatar  avatar  avatar  avatar  avatar

rhoconnect.js's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.