Updated README

This commit is contained in:
kitolog
2019-08-16 14:41:58 +03:00
parent c05f3be5a7
commit fce4efacb6
3 changed files with 41 additions and 1141 deletions
+29 -56
View File
@@ -1,89 +1,62 @@
cordova-plugin-timer cordova-plugin-zip-archive
============================ ============================
Cordova native timer plugin Cordova plugin to create zip archive
### Installation ### Installation
cordova plugin add cordova-plugin-timer cordova plugin add cordova-plugin-zip-archive
// you may also install directly from this repo // you may also install directly from this repo
cordova plugin add https://github.com/kitolog/cordova-plugin-timer cordova plugin add https://github.com/kitolog/cordova-plugin-zip-archive
## Sample usage ## Sample usage
Here is simple example of how to connect to remote server, consume data from it and close the connection. Here is simple example of how to zip files
Create instance of Socket type: Create instance of Zip plugin:
``` ```
var timer = new window.nativeTimer(); var zipInstance = new window.zipArchive()
``` ```
Set data consumer, error and close handlers: Set data consumer, error and close handlers:
``` ```
timer.onTick = function(tick) { zipInstance.onError = function(errorMessage) {
// invoked on tick
};
timer.onError = function(errorMessage) {
// invoked after error occurs // invoked after error occurs
}; };
timer.onStop during connection = function(hasError) {
// invoked after stop
};
``` ```
Start timer with delay 1ms and repeat 1000ms Archive files
``` ```
timer.start( zipInstance.zip('/PATH/TO/NEW/ARCHIVE.zip',
1, ['/PATH/TO/FILE1.txt',
1000, '/PATH/TO/FILE2.txt'
function() { '/PATH/TO/FILE3.txt'
// invoked after successful start '/PATH/TO/FILE4.csv'
}, ],
function(errorMessage) { () => {
// invoked after unsuccessful start // zip archive created
}); },
``` (error) => {
// handle errors
stop the timer })
```
timer.stop();
``` ```
## API ## API
### Event handlers ### Event handlers
#### `onTick: (data: int) => void`
Invoked after new tick is received by the timer.
#### `onStop: (hasError: boolean) => void`
Invoked after timer was stopped.
#### `onError: (message: string) => void` #### `onError: (message: string) => void`
Invoked when some error occurs during timer process. Invoked when some error occurs during zip process.
#### `on: (eventName: string, callback: function) => void` #### `on: (eventName: string, callback: function) => void`
Syntax sugar for the event handlers (onTick, onStop, onError) Syntax sugar for the event handlers (onTick, onStop, onError)
eventName: `error`, `tick`, `stop` eventName: `error`
### Methods ### Methods
#### `start(delay, interval, onSuccess?, onError?): void` #### `zip(path, files, onSuccess?, onError?): void`
Establishes connection with the remote host. Establishes connection with the remote host.
| parameter | type | description | | parameter | type | description |
| ----------- |-----------------------------|--------------| | ----------- |-----------------------------|--------------|
| `delay` | `number` | timer delay | | | `path` | `string` | zip archive path | |
| `interval` | `number` | timer tick interval | | `files` | `string array` | path to files |
| `onSuccess` | `() => void` | Success callback - called after successfull timer start. (optional)| | `onSuccess` | `() => void` | Success callback - called after archive was created. (optional)|
| `onError` | `(message: string) => void` | Error callback - called when some error occurs during timer start. (optional)| | `onError` | `(message: string) => void` | Error callback - called when some error occurs during creating an archive. (optional)|
#### `stop(onSuccess?, onError?): void`
Closes the connection. `onClose` event handler is called when connection is successfuly closed.
| parameter | type | description |
| ----------- |-----------------------------|--------------|
| `onSuccess` | `() => void` | Success callback, called after timer was stopped. (optional)|
| `onError` | `(message: string) => void` | Error callback, called when some error occurs during this procedure. (optional)|
## What's new ## What's new
- 1.0.0 - initial code - 1.0.0 - initial code
- 1.0.1 - added common event handler
- 1.0.2 - updated types
-1071
View File
File diff suppressed because it is too large Load Diff
+12 -14
View File
@@ -1,10 +1,10 @@
{ {
"name": "cordova-plugin-zip-compression", "name": "cordova-plugin-zip-archive",
"version": "1.0.0", "version": "1.0.0",
"description": "Cordova Zip Plugin", "description": "Cordova Zip Archive Plugin",
"types": "./types/index.d.ts", "types": "./types/index.d.ts",
"cordova": { "cordova": {
"id": "cordova-plugin-zip-compression", "id": "cordova-plugin-zip-archive",
"platforms": [ "platforms": [
"android", "android",
"ios" "ios"
@@ -12,23 +12,21 @@
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/kitolog/cordova-plugin-zip-compression" "url": "https://github.com/kitolog/cordova-plugin-zip-archive"
}, },
"bugs": { "bugs": {
"url": "https://github.com/kitolog/cordova-plugin-zip-compression" "url": "https://github.com/kitolog/cordova-plugin-zip-archive"
}, },
"keywords": [ "keywords": [
"cordova", "cordova",
"zip", "zip",
"archhive", "archive",
"native", "ios zip",
"native timer", "android zip",
"ios timer", "cordova zip",
"android timer", "android archive",
"cordova timer", "ios archive",
"android interval", "cordova archive",
"ios interval",
"cordova interval",
"cordova-android", "cordova-android",
"cordova-ios" "cordova-ios"
], ],