Updated README
This commit is contained in:
85
README.md
85
README.md
@@ -1,89 +1,62 @@
|
||||
cordova-plugin-timer
|
||||
cordova-plugin-zip-archive
|
||||
============================
|
||||
Cordova native timer plugin
|
||||
Cordova plugin to create zip archive
|
||||
|
||||
### Installation
|
||||
cordova plugin add cordova-plugin-timer
|
||||
cordova plugin add cordova-plugin-zip-archive
|
||||
|
||||
// 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
|
||||
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:
|
||||
```
|
||||
timer.onTick = function(tick) {
|
||||
// invoked on tick
|
||||
};
|
||||
timer.onError = function(errorMessage) {
|
||||
zipInstance.onError = function(errorMessage) {
|
||||
// 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(
|
||||
1,
|
||||
1000,
|
||||
function() {
|
||||
// invoked after successful start
|
||||
},
|
||||
function(errorMessage) {
|
||||
// invoked after unsuccessful start
|
||||
});
|
||||
```
|
||||
|
||||
stop the timer
|
||||
```
|
||||
timer.stop();
|
||||
zipInstance.zip('/PATH/TO/NEW/ARCHIVE.zip',
|
||||
['/PATH/TO/FILE1.txt',
|
||||
'/PATH/TO/FILE2.txt'
|
||||
'/PATH/TO/FILE3.txt'
|
||||
'/PATH/TO/FILE4.csv'
|
||||
],
|
||||
() => {
|
||||
// zip archive created
|
||||
},
|
||||
(error) => {
|
||||
// handle errors
|
||||
})
|
||||
```
|
||||
|
||||
## API
|
||||
### 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`
|
||||
Invoked when some error occurs during timer process.
|
||||
Invoked when some error occurs during zip process.
|
||||
|
||||
#### `on: (eventName: string, callback: function) => void`
|
||||
Syntax sugar for the event handlers (onTick, onStop, onError)
|
||||
eventName: `error`, `tick`, `stop`
|
||||
eventName: `error`
|
||||
|
||||
### Methods
|
||||
#### `start(delay, interval, onSuccess?, onError?): void`
|
||||
#### `zip(path, files, onSuccess?, onError?): void`
|
||||
Establishes connection with the remote host.
|
||||
|
||||
| parameter | type | description |
|
||||
| ----------- |-----------------------------|--------------|
|
||||
| `delay` | `number` | timer delay | |
|
||||
| `interval` | `number` | timer tick interval |
|
||||
| `onSuccess` | `() => void` | Success callback - called after successfull timer start. (optional)|
|
||||
| `onError` | `(message: string) => void` | Error callback - called when some error occurs during timer start. (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)|
|
||||
|
||||
|
||||
| `path` | `string` | zip archive path | |
|
||||
| `files` | `string array` | path to files |
|
||||
| `onSuccess` | `() => void` | Success callback - called after archive was created. (optional)|
|
||||
| `onError` | `(message: string) => void` | Error callback - called when some error occurs during creating an archive. (optional)|
|
||||
|
||||
## What's new
|
||||
- 1.0.0 - initial code
|
||||
- 1.0.1 - added common event handler
|
||||
- 1.0.2 - updated types
|
||||
- 1.0.0 - initial code
|
||||
1071
package-lock.json
generated
1071
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
26
package.json
26
package.json
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"name": "cordova-plugin-zip-compression",
|
||||
"name": "cordova-plugin-zip-archive",
|
||||
"version": "1.0.0",
|
||||
"description": "Cordova Zip Plugin",
|
||||
"description": "Cordova Zip Archive Plugin",
|
||||
"types": "./types/index.d.ts",
|
||||
"cordova": {
|
||||
"id": "cordova-plugin-zip-compression",
|
||||
"id": "cordova-plugin-zip-archive",
|
||||
"platforms": [
|
||||
"android",
|
||||
"ios"
|
||||
@@ -12,23 +12,21 @@
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/kitolog/cordova-plugin-zip-compression"
|
||||
"url": "https://github.com/kitolog/cordova-plugin-zip-archive"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/kitolog/cordova-plugin-zip-compression"
|
||||
"url": "https://github.com/kitolog/cordova-plugin-zip-archive"
|
||||
},
|
||||
"keywords": [
|
||||
"cordova",
|
||||
"zip",
|
||||
"archhive",
|
||||
"native",
|
||||
"native timer",
|
||||
"ios timer",
|
||||
"android timer",
|
||||
"cordova timer",
|
||||
"android interval",
|
||||
"ios interval",
|
||||
"cordova interval",
|
||||
"archive",
|
||||
"ios zip",
|
||||
"android zip",
|
||||
"cordova zip",
|
||||
"android archive",
|
||||
"ios archive",
|
||||
"cordova archive",
|
||||
"cordova-android",
|
||||
"cordova-ios"
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user