Refactor www/googlemaps-cdv-plugin.js
See original GitHub issueI’m submitting a … (check one with “x”)
- question
- any problem or bug report
- feature request
- contribution
If you choose ‘problem or bug report’, please select OS: (check one with “x”)
- Android
- iOS
I’d like to refactor www/googlemaps-cdv-plugin.js
as it contains a lot of complicated logic. That logic is really hard to understand, also I see there are some code duplication which adds in size in resulting app bundle (js evaluation take time especially at 1st boot).
Why?
- this will improve codebase, thus it will be easier to make contributions
- this will decrease amount of js code, so app will load faster
- this will allow to remove redundant/dead code
- this will allow to write unit tests for almost every file in the plugin
- this will allow to refactor some recursive calls with loops (loops are faster than recursion in JS)
What I eventually plan to do is to split that logic between 3 objects:
MapFactory
- responsible forMap
creation, will be used instead of massive logic ingetMap
functionMapsApi
- easy interface to make native API calls toGoogleMaps
related plugins (this will encapsulateCommand queue mechanism
). This interface I plan to build based on promisesDomObserver
- object which will walk over DOM elements and collect their rects, zIndex, etc and watch when they changed
I started to do this in my fork, so you are welcome to check the first results here. This is the initial refactoring.
Currently what I ended up with is in https://github.com/stalniy/cordova-plugin-googlemaps/tree/refactor/map . This is still not final version but very close to that. Currently I’m testing every usecase from v2.0 demo repo.
Let me know whether you interested in merging this into core project!
Thanks for awesome plugin!
P.S.: also I’d like to remove existing polyfills from the project and just add a note that this project requires that polyfills on older webviews. This will allow people to choose whatever polyfill library they like 😃 Also this will decrease the resulting js size of the plugin. Obviously this may be discussed in a separate ticket
Issue Analytics
- State:
- Created 6 years ago
- Comments:33 (30 by maintainers)
Top GitHub Comments
Hi @wf9a5m75
I think that you did is awesome! Despite the fact that there is a room for improvements, I wouldn’t be able to suggest them if you didn’t create this plugin.
Also I know that I don’t understand the whole picture. That’s why I stopped my refactoring and decided to ask for your help (guidance) in this job.
@cvaliere, I don’t think that blaming somebody will help you to create a better software. And I’d recommend to work In cooperation with others to create awesome things. Isn’t this how Open Source was created or how vendors of browsers decided to standardize JS and web?
Let’s be polite guys as we are from different cultures and may do mistakes in phrases, words or meanings when we talk using not our native language.
@wf9a5m75 I plan to spend some time today looking into your comments and fixing them. Thanks for the guidance, your work and patience!
Since the refactoring is done at once, I close this thread. But please send a new pul request with improvement. I really appreciate for your help.