@titanium/streams

1.0.41 • Public • Published

Preparing for end of Axway

👇   support for Amplify Cloud and Mobile   👇

RIP Axway Amplify Titanium (2010 - 2022)

🪦   RIP Axway Amplify Titanium (2010 - 2022)

🪦   RIP Axway Amplify Cloud Services (2012 - 2022)

🪦   RIP Axway Amplify Crash Analytics (2015 - 2022)


🛑    Axway support for Amplify products has ended for most products related to mobile and cloud.

A few of the open-source versions of Axway Amplify products will live on after Axway Amplify End-of-Life (EOL) announcements. However, all closed-source projects and most open-source projects are now dead.

 

👉    A group of Axway employees, ex-Axway employees, and some developers from Titanium community have created a legal org and now officially decide all matters related to future of these products.

 


API FAQ:

 

Click to watch on Youtube

  ↑ Watch video on YouTube ↑

 

 


 

 

@titanium/streams

https://www.npmjs.com/package/@titanium/streams

Titanium Native mobile SDK for AMPLIFY Streams

📝 Description

AMPLIFY Streams is a real-time cache proxy allowing you to poll standard public REST APIs and push updates to clients. But wait, there is more! AMPLIFY Streams keeps an history of modifications that occur on the data between two polling! This way, AMPLIFY Streams is able to give you the list of modifications which happened since last time you fetched the data.

In other words, AMPLIFY Streams is the perfect cache to dramatically reduce the bandwidth consumption to transfer data that change both rarely and frequently.

AMPLIFY Streams Titanium SDK is based on Axway AMPLIFY Streams JavaScript SDK

Features

  • [x] Incremental data update: replacing polling by push is not enough to minimize data streams. That's why streamdata.io pushes only the part that has changed.
  • [x] Server-Sent-Events (SSE): updates are pushed to the client using SSE protocol. By providing fallback mechanisms streamdata.io can also work with older browsers.
  • [x] API Cache: to reduce server load and latency, streamdata.io has an integrated cache mechanism.

🚀 Getting Started

Installing

Please ensure there is a package.json file in the target directory. If there is not one present, you can create one with npm init.

If you wish to install this in an app using Titanium Turbo, you can execute this in the project root directory:

npm install @titanium/streams

If you wish to install this in an app using Titanium Alloy, you can execute the following in the project root directory:


cd app
npm install @titanium/streams

Connect to your API

Create a StreamDataEventSource object into your JavaScript code.

    var myEventSource = streamdataio.createEventSource("http://mysite.com/myRestService", <app_token>);

The StreamDataEventSource is the entry point for establishing a data stream connection to the given URL.

It uses an application token to identify and authorize the stream connection to be established.

To get a valid token, please visit streamdata.io web site to register and create an application.

It uses standard HTTP Server-Sent Events to get the data you required through streamdata.io proxy.

If your API requires specific headers, simply pass them as an array on the event source creation, and streamdata.io will forward them to your Information System.

An optional headers parameter can be passed to the createEventSource method.

It must be an array with the following structure:

['header1: headervalue1', 'header2: headervalue2']

Here is an example to add a Basic authorization header to your target API call:

    // Your api URL
    var url = 'http://mysite.com/myJsonRestService';

    // add whatever header required by your API
    var headers = ['Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=='];

    var myEventSource = streamdataio.createEventSource(url,<app_token>, headers);
	

Handle received data

Axway Streams SDK handles data from the targeted REST service as JSON objects.

When the StreamDataEventSource object is opened, the initial set of data is returned as it would be with a standard call to the service URL. This data set is called the snapshot. The SDK returns it through the onData callback.

The updates of this initial set will come subsequently in the JSON-Patch format through the onPatch callback. Such a data update is called a patch.

You can define your callback functions as follows:

    myEventSource.onData(function(data){
        // initialize your data with the initial snapshot
    }).onPatch(function(patch){
        // update the data with the provided patch
    }).onError(function(error){
        // do whatever you need in case of error
    }).onOpen(function(){
        // you can also add custom behavior when the stream is opened
    });

Start receiving data

    myEventSource.open();

🔗 Related Links

  • Titanium Mobile - Open-source tool for building powerful, cross-platform native apps with JavaScript.
  • Titanium Alloy - MVC framework built on top of Titanium Mobile.
  • Appcelerator - Installer for the Appcelerator Platform tool
  • Titanium Turbo - Variation of Titanium Alloy that adds some enhancements and customizations for rapid development.
  • Geek Mobile Toolkit - Toolkit for creating, building, and managing mobile app projects.

📚 Learn More

📣 Feedback

Have an idea or a comment? Join in the conversation here!

©️ Legal

Alloy is developed by Appcelerator and the community and is Copyright © 2012-Present by Appcelerator, Inc. All Rights Reserved.

Alloy is made available under the Apache Public License, version 2. See their license file for more information.

Appcelerator is a registered trademark of Appcelerator, Inc. Titanium is a registered trademark of Appcelerator, Inc. Please see the LEGAL information about using trademarks, privacy policy, terms of usage and other legal information at http://www.appcelerator.com/legal.

Package Sidebar

Install

npm i @titanium/streams

Weekly Downloads

1

Version

1.0.41

License

MIT

Unpacked Size

35 kB

Total Files

19

Last publish

Collaborators

  • secure-bot
  • brentonhouse