Skip to content

Commit

Permalink
docs(DEVELOPER.MD): Adds steps for adding new plugins to index.ts (#444)
Browse files Browse the repository at this point in the history
* Adds steps for updating index.ts

* Adds .DS_Store to gitignore

* Adds step for exporting
  • Loading branch information
amuramoto authored and ihadeed committed Aug 17, 2016
1 parent abd706f commit 22ab575
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,3 +1,4 @@
.DS_Store
node_modules/
.idea
dist/
Expand Down
52 changes: 52 additions & 0 deletions DEVELOPER.md
Expand Up @@ -102,6 +102,58 @@ The `@Cordova` decorator has a few more options now.

`clearFunction` is used in conjunction with the `observable` option and indicates the function to be called when the Observable is disposed.

### Updating index.ts

For new plugins, you will need to update `/src/index.ts` to properly export your plugin and make it available for use.

1. Import the plugin class into `index.ts`:

`import {PluginClassName} from ./plugins/filenameForPlugin`

No need to put the `.ts` extension on the filename.

2. Add the plugin class name to the list in the `export` object:

```
export {
ActionSheet,
AdMob,
AndroidFingerprintAuth,
YourPluginClassName,
...
}
```

3. Add the plugin class name to the `window['IonicNative']` object:

```
window['IonicNative'] = {
ActionSheet: ActionSheet,
AdMob: AdMob,
AndroidFingerprintAuth: AndroidFingerprintAuth,
YourPluginClassName: YourPluginClassName,
...
```

4. If your plugin exports any other objects outside of the plugin class, add an export statement for the file:

`export * from './plugins/filenameForPlugin';`

No need to put the `.ts` extension on the filename.

For example, `googlemaps.ts` exports a const outside of the plugin's main `GoogleMap` class:

```
export const GoogleMapsAnimation = {
BOUNCE: 'BOUNCE',
DROP: 'DROP'
};
```

To properly export `GoogleMapsAnimation`, `index.ts` is updated with:

`export * from './plugins/googlemaps';`

### Testing your changes

You need to run `npm run build` in the `ionic-native` project, this will create a `dist` directory. Then, you must go to your ionic application folder and replace your current `node_modules/ionic-native/dist/` with the newly generated one.
Expand Down

0 comments on commit 22ab575

Please sign in to comment.