Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ardriveapp/ardrive_http
A Dart/Flutter package to perform network calls. It uses Isolates to perform network calls on Dart VM environments and WebWorkers on Web.
https://github.com/ardriveapp/ardrive_http
Last synced: 3 days ago
JSON representation
A Dart/Flutter package to perform network calls. It uses Isolates to perform network calls on Dart VM environments and WebWorkers on Web.
- Host: GitHub
- URL: https://github.com/ardriveapp/ardrive_http
- Owner: ardriveapp
- License: agpl-3.0
- Created: 2022-12-02T15:11:25.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-15T21:11:56.000Z (11 months ago)
- Last Synced: 2023-12-15T22:35:38.571Z (11 months ago)
- Language: Dart
- Homepage:
- Size: 33.2 MB
- Stars: 2
- Watchers: 4
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ArDriveHTTP
ArDriveHTTP is a package to perform network calls for ArDrive Web. It uses Isolates to perform network calls on Dart VM environments and WebWorkers on Web.
### Features
- Standarized network calls
- Support retries
- Use Isolates and WebWorkers to reduce impact on UI process### Implemented methods
- get()
- getJson()
- getAsBytes()## Getting started
In order to use this package you need to copy `ardrive-http.js` and `workers.js` from `js/dist` folder to your project's `web` folder so they can be dynamic imported when some `ArDriveHTTP` method is called.
## Usage
Simply create a new instance of `ArDriveHTTP` and pass the follow optional params:
- `retries`: amount of retry attempts
- `retryDelayMs`: base retry delay in ms
- `noLogs`: to hide logs```dart
// Using defaults
final http = ArDriveHTTP()// Setting params
// Retry 4 times
// Initial delay of 100ms
// Don't log requests
final http = ArDriveHTTP(
retries: 4,
retryDelayMs: 100,
noLog: true,
);
```Call the intended method like:
```dart
// Get raw response
final response = await ArDriveHTTP().get(url: 'https://url');// Get JSON response
final jsonResponse = await ArDriveHTTP().get(
url: 'https://url',
isJson: true,
);
// OR
final getJsonResponse = await ArDriveHTTP().getJson('https://url');// Get bytes
final bytesResponse = await ArDriveHTTP().get(
url: 'https://url',
asBytes: true,
);
// OR
final getBytesResponse = await ArDriveHTTP().getAsBytes('https://url');
```## Building
### Typescript
This project uses NodeJS version 18 and Yarn.
All the typescript code used by ArDriveHTTP to run network calls in the browser lives in the `js` folder.#### Getting dependencies
```sh
yarn
```#### Building
```sh
yarn build
```This command will transpile and bundle all typescript code to a minified javascript file called `ardrive-http.js` in `dist` folder.
#### Watching
You can use the following command to automatically rebuild the javascript file whenever a change in the code happens:
```sh
yarn watch
```