Streaming json in nativescript - nativescript

has anyone used the streaming json in nativescript? I found this http://oboejs.com/why but it seems not to work. I'm using nativescript 1.6, any suggestion would be appreciated really much. Thank you.

There is no library to my knowledge currently built for NativeScript that allows streaming JSON. Just for clarification sake you can easily pull JSON from a server and parse it using the built in fetch/http api's, right now -- but their is no way to have it start parsing the json as it downloads in chunks built in.
You can attempt to modify the npm node module to build for NativeScript.
Or thinking outside the box a bit; you can also use the web based version of that module inside the nativescript-webworkers and have it pull and process your JSON and communicate the json messages back to the NS environment. The WebWorkers module actually wraps the native platform's web browser module so it can run all browser based JS code.
Disclaimer: I'm the author of the open source NativeScript-WebWorkers.

Related

Parse Image + Parse httpRequest replacements — migrating from Parse Cloud Code to Parse Server on Node (Heroku / AWS / DO)

I found that when using the parse-node package, you can no longer use Parse.Cloud.httpRequest. I also know that Parse's Image object won't be available.
So far, I've been able to replace some Parse promises with native ones and use axios to make network requests.
However, I'm relatively new to Node, so I'm curious as to what are the most direct replacements for these, and how do I use them?
You should still be able to use Parse.Cloud.httpRequest. But axios is a great library and it's a great idea to start using it if you want to learn nodejs. When it comes to the parse-image it has to be replaced. There is a library which claims 100% compatibilty, check it out here.

Angular2 i18n at this point?

We decided to give it a spin and we started fresh project using Angular2. So far so good, but at this point we're facing an issue. At this point, what is the proper approach to i18n for Angular2? We've researched a little and found this:
https://github.com/angular/i18n
However last commit is more than 5 months old... Doesn't look like active development.
Anyone tried using angular-translate or angular-gettext? Or maybe with Angular2 it's better to wrap something JS like i18next? Anyone could share their thoughts? Maybe you faced the same problem?
Plunk was updated to Angular 2 Final: https://plnkr.co/edit/4euRQQ. Things seem to work the same as in RC7.
New i18n section has been added to Angular 2 official docs. Basically, it explains in details what happens in the plunkr above.
XLIFF is the only format for translations, no json support.
A translation source file (xliff, xlf) should be created using ng-xi18n tool:
package.json:
"scripts": {
"i18n": "ng-xi18n",
...
}
and
npm run i18n
See the Merge translation section for details about merging a translation into a component template. It's done using SystemJS Text plug-in.
Another example using Gulp http://www.savethecode.com/angular2-i18n-native-support/
Older staff:
Update based on RC7 and links provided by Herman Fransen:
I've made a minimal Plunkr example: https://plnkr.co/edit/4W3LqZYAJWdHjb4Q5EbM
Comments to plunkr:
bootstrap should provide TRANSLATIONS, TRANSLATIONS_FORMAT, LOCALE_ID with values -> setup translations
translatable items in html-templates should use directive i18n
translations are stored in .xlf file. Ties between languages is done through Id, ties with html by a value of <source> tag in xlf
currently xlf files are not used directly; a .ts file is manually created to wrap the content of xlf in an exportable variable. I guess, this should be working automagically in final release (maybe even now).
This is the first officially documented approach I found.
However, it's still barely usable. I see the following issues in the current implementation:
Language is set at bootstrap, unable to change it in run-time. This should be changed in Final.
Id of a translatable item in xlf is generated SHA. Current way to get this id is a bit messy: you create a new translatable item, use it, copy SHA id from error and paste into your i18n.lang.xlf file.
There is a big documentation pull request concerning i18n
Older staff:
Release notes https://github.com/angular/angular/blob/master/CHANGELOG.md have a record
i18n: merge translations 7a8ef1e
A big chunk of i18n was introduced in Angular 2 RC5
Unfortunately, still no documentation available.
Everyone's eager for the official implementation, but this one worked for my use case:
https://github.com/ocombe/ng2-translate
README is fairly thorough, and if you need something real particular (for me it was code-splitting) the code itself isn't too long or hard to read.
Support for i18n is now official in Angular 2 RC6
Official release blog:
https://angularjs.blogspot.nl/2016/09/angular-2-rc6_1.html
A sample of internationalization with Angular 2 RC6
https://github.com/StephenFluin/i18n-sample
More info how the new concept of i18n works in angular2:
https://lingohub.com/blog/2015/03/angular-2-i18n-update-ng-conf-2015
I found another way to implement this using pipe and service
HTML
<!-- should display 'hola mundo' when translate to Spanish -->
<p>{{ 'hello world' | translate }}</p>
TYPESCRIPT
...
// "this.translate" is our translate service
this.translate.use('es'); // use spanish
...
// should display 'hola mundo' when translated to Spanish
this.translatedText = this.translate.instant('hello world');
...
https://scotch.io/tutorials/simple-language-translation-in-angular-2-part-1
https://scotch.io/tutorials/simple-language-translation-in-angular-2-part-2
There is an official support for i18n in Angular.io here:
https://angular.io/docs/ts/latest/cookbook/i18n.html
But! As mentioned in docs:
You need to build and deploy a separate version of the application for
each supported language!
That makes this feature useless in most cases ...
Unless you will use it without CLI as described here:
https://devblog.dymel.pl/2016/11/03/angular2-and-i18n-translate-your-app/
I am putting together a POC and the official documentation is cumbersome to say the least, so I tried ngx-translate http://www.ngx-translate.com/ and I literally had the hello world working in a few minutes, there are few caveats:
I've read of people complaining about performance, because of the pipes, but reading the github issues, it seems that it is getting resolved
It is only for i18n or Translations it does not deal with i10n or Localization
There are few warning errors with Angular4 but it works anyways
long story short I liked ngx-translate if you have a small app and only need translation
I personally wanted Localization, so I am looking at
https://github.com/robisim74/angular-l10n
. It looks pretty good, but I haven't tested, so I'll let you know later, or you guys can go and we all try

node-webkit equivalent for sinatra?

I've been thinking about learning how to make simple Mac OS X applications based on web-technology and I came across node-webkit which seems compelling. However, I've recently invested in learning the basics of Sinatra/Ruby and I wanted to stay on that course.
Is there a "node-webkit equivalent" for developers who use Sinatra? Or, is there a recommended way to use the Sinatra framework (or Ruby) to build OS X apps that are essentially web wrappers?
Sinatra is a server-side framework.
Contrary to Node-webkit which is on client side.
If you need to interact with a server, you can still use sinatra (as well as node.js, php, ...) on your server.
But if you are looking for a framework like sinatra on node.js, you should look into Express.js : https://npmjs.org/package/express
Node-webkit can use file or http, and which to use depends on your needs. The majority of the time you shouldn't need to, Node-webkit runs completely client-side using only HTML, javascript, and css. You certainly can initialize a local webserver when Node-webkit loads, but first try making a basic "Hello World" application to learn how it works.
If you still think you need to spin up a web server, then the code might look something like this (I'm using Express.js):
// Retrieve libraries...
var expressPort = 6014
var NodeWebkit = require('nw.gui');
// Call focus to application...
NodeWebkit.Window.get().focus();
// Instantiate the Express Server...
var spawn = require("child_process").spawn;
spawn("node", ['./server/server', expressPort]);
// Request director page...
window.location.replace('http://localhost:'+expressPort);
In order to use the Node-webkit features from a page on localhost you will also need to add the following line beneath the root of your package.json:
node-remote": "<local>
Note: While this does work, you must really consider whether it makes sense. In other words, is you application fully self-contained? If nothing will access that content except the application then you don't need it.
For my application I am using Node-webkit as an admin console for creating/managing broadcasts. (hence the local webserver)
Nw is not a web framework. Nw does not use a http protocol; it does use a file protocol.
Nw is composed of chromium and nodejs, which allows you to run both DOM and node.js stuff -- without setting up a web server.

Ajax file upload in node.js

I want to upload ajax file upload which uses xhr to send file data,
at client m using this
http://valums.com/ajax-upload/
how i will accept this data on node and save the file to server by node.js , which module i need to use in node.js?
I've created an uploader with progress bar using the formidable module, it's really easy to use and provides a lot of useful callbacks.
Have a look here:
https://github.com/felixge/node-formidable (scroll down to get the Docs)
http://debuggable.com/posts/parsing-file-uploads-at-500-mb-s-with-node-js:4c03862e-351c-4faa-bb67-4365cbdd56cb
due to the lack of an example file in valums ajax-uploader, I've just created one.
It catches up the XHR upload if possible, alternatively falling back to the old form-based method.
All in conclusion to valums ajax-uploader.
https://github.com/aldipower/file-uploader/blob/master/server/nodejs.js
Maybe Valums will accept the pull request some time and the sample file gets merged in the standard repository.

PlayBook Webworks cannot read local files

I'm making a PlayBook webworks application. I am having problems reading a local file.
I want to make an XSLT transformation using a remote XML and a local xsl file.
I am able to download an external xml file using XMLHttpRequest, but i cannot read a local file.
I tried to read it unsing the local:/// and using relative path, but always get my XMLhttprequest status response code = 0.
Any ideas?
Thanks in advance,
Jordi Gaset
Local file access in WebWorks is not supported yet as of the v1.0.0.23 Beta3 SDK.
Sadly the only way I could get this to work was to store my local data as json instead of xml, then make use of the sql lite HTML5 database to store anything inside of the app. I think the webworks sdk needs to have their own implementation of the xmlhttprequest object that gets around all of these crazy cross-domain issues. I tried for a while to use webworks, gave up, and started to use the air sdk.

Resources