4.0.23 • Published 6 years ago

marshalling v4.0.23

Weekly downloads
10
License
MIT
Repository
github
Last release
6 years ago

MIT Licence npm npm Build Status

Marshalling

The most stable version is 4.0.19 and above. Marshalling serving data from server response to client! Marshalling is a Typescript Framework for React Native!

To use with your next React Native simply install by: npm install marshalling

Please note that Marshalling is written in Typescript it is important that your project can render tsc. A good article can be read at https://medium.com/@rintoj/react-native-with-typescript-40355a90a5d7

Please feel free to download the demo application of Marshalling from: https://github.com/MarshalPaterson/Marshalling-ReactNative

The demo application has an example for 'GET' and 'POST'. Support for CRUD is still under development.

General Usage: import * as Marshalling from "marshalling";

Create an instance within your class: public marshalling = new Marshalling.Marshall();

In componentDidMount set the method signatures of name and service api endpoint. Then call the end via the 'law' method. The 'law' method is a Promise method that you assign your callback functions, the example below you can see on success it handles the responses with a 'value' arrow function and on error in 'reason' arrow function. The endpoint returns a JSON can be parsed into a object then set to state.

componentDidMount() {
    this.marshalling.getInstance().addService('tester', 'https://jsonplaceholder.typicode.com/comments');
    this.marshalling.getInstance().law('tester').then(
     (value) => {
        let obj = JSON.parse(String(value));
        this.setState({
          data: obj[0].name
        });
    },
    (reason) => {
        console.error('Something went wrong', reason);
    });
  }

To have multiable calls to an API you can simply register the service then call on a promise.all for example:

let marshalling = new Marshalling.Marshall();
marshalling.getInstance().addService('comments', 'https://jsonplaceholder.typicode.com/comments');
marshalling.getInstance().addService('albums', 'https://jsonplaceholder.typicode.com/albums');

Promise.all([marshalling.getInstance().law('comments'), marshalling.getInstance().law('albums')]).then(function(
	values
) {
	console.log(values);
});

Marshalling implements the Singleton pattern. If you are not using Typescript you can still reference Marshalling in a normal ES6 Javascript project.

NOTE: Be mindful on the scope of the 'marshalling' variable, you may or may not need to use 'this.' keyword.

For older version please review branch 3.5.0. https://github.com/MarshalPaterson/Marshalling/tree/3.5.0

Join Marshalling on LinkedIn at https://www.linkedin.com/groups/13534575

For a demo that works with React Native, Marshalling, React Navigation and The Granary please go here: https://github.com/MarshalPaterson/TheGranaryMarshallingNavigation

4.0.23

6 years ago

4.0.22

6 years ago

4.0.21

6 years ago

4.0.20

6 years ago

4.0.19

6 years ago

4.0.18

6 years ago

4.0.17

6 years ago

4.0.16

6 years ago

4.0.15

6 years ago

4.0.14

6 years ago

4.0.13

6 years ago

4.0.12

6 years ago

4.0.11

6 years ago

4.0.10

6 years ago

4.0.9

6 years ago

4.0.8

6 years ago

3.6.13

7 years ago

3.6.12

7 years ago

3.6.11

7 years ago

3.6.10

7 years ago

3.6.9

7 years ago

3.6.8

7 years ago

3.6.7

7 years ago

3.6.6

7 years ago

3.6.5

7 years ago

3.6.4

7 years ago

3.6.3

7 years ago

3.6.2

7 years ago

3.6.1

7 years ago

3.6.0

7 years ago

3.5.0

7 years ago