Permalink
Browse files

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
  • Loading branch information...
1 parent abd706f commit 22ab575dd0b0c06b155144dcde2eb4d9e9c6721f @amuramoto amuramoto committed with ihadeed Aug 17, 2016
Showing with 53 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +52 −0 DEVELOPER.md
View
@@ -1,3 +1,4 @@
+.DS_Store
node_modules/
.idea
dist/
View
@@ -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.

0 comments on commit 22ab575

Please sign in to comment.