Index ¦ Archives  ¦ Atom  ¦ RSS

Enyo - Service With Consistent Parameters

In WebOS, services live as long as you have an outstanding call with them plus 30 seconds. Once that ends, the service is closed and any data it was storing temporarily is gone. Therefore, since I have an app that needs the username/password of my user for all requests, as it communicates with a web API, I basically have to send it with every call.

I don't like boilerplate code so to DRY my code I created this kind (it inherits from my previous RetryService, but if you change that to PalmService it should work fine). Just call setParams() whenever you get the data. It's a single-use situation because I need the static data for when I use the service with different owners. If you think of a better way, feel free to let me know.

        AlwaysParamsService.params = params;
    call:function(inParams, inProps){
        // from the top of
        var props = inProps || {};
        props.params = props.params || inParams || this.params || AlwaysParamsService.params || {};

        props.params = enyo.mixin(enyo.clone(props.params), AlwaysParamsService.params);
        arguments[1] = props;

© Fahrzin Hemmati. Built using Pelican. Theme by Giulio Fidente on github.