Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export sqlitePlugin object #382

Open
axemclion opened this issue Nov 14, 2015 · 5 comments
Open

Export sqlitePlugin object #382

axemclion opened this issue Nov 14, 2015 · 5 comments

Comments

@axemclion
Copy link

The www folder currently assigns sqlitePlugin object to root here. root is assigned to this, which happens to be window in case of Cordova, and so the plugin currently works.
However, cordova plugins require a module.exports so that the clobbers specified in plugin.xml works.
Suggested solution - add module.exports = root.sqlitePlugin at the end of the function here.

This error surfaced, when this plugin was used in ReactNative (example) using the react-native-plugin-adapter.

Tracked in this issue - axemclion/react-native-cordova-plugin#4

@axemclion
Copy link
Author

If you are ok, I can send in a pull request for this.

@brodycj
Copy link
Contributor

brodycj commented Nov 14, 2015

Thanks @axemclion. I still have to think about this a little. While a pull request is always welcome, your description with the Suggestion solution above is clear enough. Assuming I do include this I will be sure to give you the credit for the fix (along with the change to the CoffeeScript version to keep it up-to-date).

@brodycj
Copy link
Contributor

brodycj commented Nov 14, 2015

Also, I really like your react-native-cordova-plugin project and wish I had found it earlier. I will add a link to README.md when I get a chance. I suggest that you do not close axemclion/react-native-cordova-plugin#4 until we get this fixed.

The one thing I have against this change is that there are a couple of cases where I will need to support using SQLitePlugin.js outside of the Cordova framework. One example that I am working on is using the plugin from a web worker, where I really cannot use cordova.js and have to build another Javascript-native communication system.

I am planning to make a separate version to support some other extra features and am thinking about including the suggested solution there instead.

@axemclion
Copy link
Author

@brodybits I think that one solution could be to have all the core logic in one file, say SQLitePlugin.js, and then have adapters, once for webworkers, another for Cordova, etc. This way most of the logic will still be shared, and cordova specific parts are simply moved to a specific file.

brodycj pushed a commit to brodycj/Cordova-sqlite-storage-common-dev that referenced this issue Nov 16, 2015
Update for @andpor/react-native-sqlite-storage also working for Android
ref: storesafe#382
brodycj pushed a commit to brodycj/Cordova-sqlite-storage-common-dev that referenced this issue Nov 16, 2015
Update for @andpor/react-native-sqlite-storage also working for Android
ref: storesafe#382
brodycj pushed a commit to brodycj/Cordova-sqlite-storage-common-dev that referenced this issue Nov 16, 2015
Update for @andpor/react-native-sqlite-storage also working for Android
ref: storesafe#382
@brodycj
Copy link
Contributor

brodycj commented Nov 17, 2015

@axemclion I would like to hold off on this for now. It would need some tweaking to work in a web worker, and also the suggested solution did not really work for me. There is now https://github.com/andpor/react-native-sqlite-storage that ports this project to React Native and I will recommend this in axemclion/react-native-cordova-plugin#4.

I am thinking to follow the advice in http://blog.vjeux.com/2011/javascript/javascript-one-line-global-export.html when I get around to this unless I find a better idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants