1.7.12 • Published 5 years ago

@tracksale/resources v1.7.12

Weekly downloads
1
License
MIT
Repository
-
Last release
5 years ago

Resouces

The resourcer are objects that we use to communicate with an API and retrive data to our components. To establish this communication we use Axios as a HTTP client, so we can fetch data from internet without a problem. Another library that you need to be used to is ApiSauce wich gives axios access to information like "Something gone wrong?", "What did the api return?".

Nathan has developed a simple way to create resources into this repository and it consists of a method called createResource() that you can find in src/cdk/resources/resource.ts. To create and use resources as components just follow the guide bellow:

  1. Create a folder into src/cdk/resources with the name of your resource. For example: src/cdk/resources/teams. Here is where we'll configure our component.

  2. Let's instatiate our resource. To do this, create a typescript file into the folder of the previous step and give it your resource name, just like the example: src/cdk/resources/teams/teams.ts.

  3. Into the file created previously you'll need to add some code. Use the code bellow as an example and don't forget to modify it to fit your needs.

// Import the interface to fetch from API (Modify it)
import { Team } from '@tracksale/interfaces/Team';
// Import the createResource function
import { createResource } from '../resource';

// Create your resource as an instance returned by createResource
export const teamsResource = createResource<Team>('/teams');
  1. As the last step, create a file named index.ts into the folder created in step 2 and export everything in your resource, just like the example:
export * from './teams';
  1. To use your resource, just import it in your file, like the example bellow.
import { teamsResource } from 'relative_path_of_folder/teams';
1.7.12

5 years ago

1.7.11

5 years ago

1.7.10

5 years ago

1.7.9

5 years ago

1.7.8

5 years ago

1.7.7

5 years ago

1.7.6

5 years ago

1.7.5

5 years ago

1.7.4

5 years ago

1.7.3

5 years ago

1.7.2

5 years ago

1.7.1

5 years ago

1.7.0

5 years ago

1.6.7

5 years ago

1.6.6

5 years ago

1.6.5

5 years ago

1.6.4

5 years ago

1.6.2

5 years ago

1.6.1

5 years ago

1.6.0

5 years ago

1.5.2

5 years ago

1.5.1

5 years ago

1.5.0

5 years ago

1.4.9

5 years ago

1.4.8

5 years ago

1.4.7

5 years ago

1.4.6

5 years ago

1.4.6-alpha.55

5 years ago

1.4.6-alpha.54

5 years ago

1.4.5

5 years ago

1.4.4

5 years ago

1.4.2

5 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.0

5 years ago

1.2.5

5 years ago

1.2.4

5 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.18.0

5 years ago

0.17.0

5 years ago

0.16.2

5 years ago

0.16.0

5 years ago

0.14.1

5 years ago

0.14.0

5 years ago

0.13.3

5 years ago

0.13.2

5 years ago

0.13.1

5 years ago

0.13.0

5 years ago

0.12.0

5 years ago

0.11.0

5 years ago

0.10.0

5 years ago

0.9.2

5 years ago

0.9.1

5 years ago

0.9.0

5 years ago

0.8.1

5 years ago

0.8.0

5 years ago

0.7.0

5 years ago

0.6.4

5 years ago

0.6.3

5 years ago

0.6.2

5 years ago

0.6.1

5 years ago

0.6.0

5 years ago

0.5.0

5 years ago

0.4.1

5 years ago

0.3.4

5 years ago

0.3.3

5 years ago

0.3.2

5 years ago

0.3.2-alpha.0

5 years ago

0.3.1-alpha.0

5 years ago

0.3.0-alpha.0

5 years ago

0.2.0-alpha.0

6 years ago

0.1.0-alpha.0

6 years ago

0.0.0

6 years ago