docs(DEVELOPER.MD): Adds steps for adding new plugins to index.ts (#444)

* Adds steps for updating index.ts

* Adds .DS_Store to gitignore

* Adds step for exporting
This commit is contained in:
Alex Muramoto 2016-08-17 00:11:52 -07:00 committed by Ibrahim Hadeed
parent abd706f435
commit 22ab575dd0
2 changed files with 53 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.DS_Store
node_modules/
.idea
dist/

View File

@ -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.