Giter Site home page Giter Site logo

ng-retrofit's Introduction

ng-retrofit

Installation

npm install ng-retrofit

ng-retrofit provide additional functions and customization for angular2-rest https://github.com/Paldom/angular2-rest

it's use annotations to consume Angular2 HTTP client RESTful services.

  • No need to implment or extend any interface or class
  • Add custom function before every request, like show Progress Dialog
  • Add custom function after every request, like dismiss Progress Dialog
  • You be able to disable or enable the previous functions for a custom request
  • Default header for every request
  • Custom header for custom request
  • Class routing prefix that will apply to all functions in that class
  • You can remove class routing prefix for custom method
  • Easy way to return dummy response from dummy function

Using

in your app model add our class RetrofitAngular to your providers like this


{provide: RetrofitAngular, useClass: RetrofitAngular.setConfig(
{
baseUrl:"http://192.168.1.200:3000/",
isTest:true,
responseFromDummyFunction:TEST.getDummyServiceResponse,
  defaultHttpHeaders:new AngularHeaders({"Content-Type":"application/json"}),
globalFunctionBeforeEveryRequest:SV.showProgressDialog,
globalFunctionAfterEveryRequest:SV.dismissProgressDialog
}
)
}

then you can make a service like this


@GET("/wcm/promotions/{lang}/{customerNumber}")
public getPromotions(@Path("lang")lang:string,@Path("customerNumber")customerNumber:number): Observable<any>  {return null;};

then consume the request like a method and handle returned Observable


getPromotions("EN",1234,).subscribe((promotions=>{
that.promotions=promotions;
}), this.handleFailure);

tsc RetrofitAngular.ts --sourceMap

ng-retrofit's People

Contributors

bahgatmashaly avatar

Stargazers

 avatar  avatar

Watchers

 avatar

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.