Labs

Early Fuse Experiment… porting the Angular-Resource Module to Fuse

Fuse is a cool new front-end technology, probably the coolest alternative right now creating cross platform mobile applications with Native Performance…

I do a lot of CRUD applications, so as part of the learning process, I decided to experiment with how it would be to port the omni-present Angular-Resource (https://docs.angularjs.org/api/ngResource/service/$resource) module to be used in Fuse.

This is still very very early stuff, I just wanted to share it quickly to inspire other people just starting out with Fuse to tinker themselves and share their own cool stuff…

Anyways, enough talking, let’s get to it…

My first task was to use the fetch operation which is the recommended way to make network requests via HTTP, it’s a first-class citizen in Fuse which resembles the same status it will take the browser in the future…
You can read more about the proposed standard for the Fetch API here:
https://developer.mozilla.org/en/docs/Web/API/Fetch_API

My experiment is based on the lab recently published by Jake from FuseTools… basically just replacing his call to fetch with a call to the Get operation on my resource implementation, which eventually wraps and uses fetch…
https://github.com/yupferris/fuse-example-fetching-and-displaying-data

It illustrates how it’s relatively easy to implement a 3rd party reusable library and how it can be imported into your Fuse project.

The standard used is CommonJS, and contrary to what FuseTools document themselves, I found during my experiment that its possible to both use the advised syntax of module.exports, but also the less convoluted syntax of exports.[memberName], which is the default for e.g. the TypeScript compiler.

I have included a link to an archive at the end of the post which contains all the files required for the experiment, please feel free to play around with it.

If you are interested in contributing to the further development of the fuse-resource module, please take a look here (https://github.com/pmoelgaard/fuse-resource).

Until an official TypeScript definition is released for Fuse, I’m maintaining my own definition which allows me to compile against the global members of Fuse…
https://github.com/pmoelgaard/fuse

Now, this is very early stuff, so please understand that it’s very rough around the edges and covered in wet paint, and that I’m only sharing it because I’m very excited of where Fuse is taking the next generation of cross-platform development for both mobile, but also desktop, which is one of the really cool features of Fuse…

Example usage

Download the project files from here: http://cl.ly/16280D0n1L0I

Advertisements