-
Notifications
You must be signed in to change notification settings - Fork 195
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
Clean the "update" event signature #105
Comments
Hello,
I agree with you, we could forget the backward compatibility.
The initial purpose of these options was to be able to reset all options currently set for the plots, areas and links before updating them. For example, you add a plot with fill:red and opacity:50%. If you update that plot with fill:blue, the plot will be blue but still with an opacity of 50%. By setting resetPlot to true, the previous opacity option would be removed at update. It's a bit weird because resetXXX doesn't delete anything from the map. This is why I have suggested a more straightforward option 'replace' that could also be named 'clear' or 'reset' which the purpose would be to reset the map at it initial state (by deleting all plots, links, areas, legends, clearing current options object, etc). But I'm wondering if such an option would be usefull, because it can be achieved easily by emptying the container through jQuery and by calling again $.mapael() on it to recreate the map with the new configuration.
I agree with you, but a prefer 'deletePlotKeys' or 'deletePlotIds' (the same for the links). What do you think ? By the way, maybe I should open a new issue for that, but I was thinking about the 'setLegendElemsState' option today. I think it should be great to be able to tell which kind of elements we want to hide or show : 'areas', 'plots' or 'links', and for which interval of values (if the elements are associated to one or more value(s), it has to be compatible with multiple valued elements). For example : "I want to show only the plots which the associated value is between 1000 and 1200) :
It would allow to play with some sliders in order to allow users to select ranges of values for which we want to show the elements. What do you think about it ? |
I just saw your PR #106 that add "all" value for deletedPlots and deletedLinks options. Maybe this is the good alternative for the resetPlots and resetLinks options ? |
I do agree with
Yes, now that I understand the concept behind the
Nice idea! But we should open a new issue to discuss its implementation indeed. |
Here is a proposal for the new signature: var options = {
mapOptions: {}, // was updatedOptions
replaceOptions: false // whether mapsOptions should entirely replace current map options, or just extend it,
newPlots: {}, // was newPlots
newLinks: {}, // was opt.newLinks
deletePlotKeys: [], // was deletedPlots
deleteLinkKeys: [], // was opt.deletedLinks
setLegendElemsState: true, // was opt.setLegendElemsState
animDuration: 0, // was opt.animDuration
afterUpdate: function(){} // was opt.afterUpdate
};
$(".container").trigger('update', [options]); |
Hello,
You are right :-) I agree with your signature proposal, I think it the "udate" event will be a lot more clear and clean with this new signature ! |
FYI, I opened the corresponding issue here: #110 |
I just saw that in your website, you are saying:
http://www.vincentbroute.fr/mapael/#overview I fear if they come here and download the main/latest, they will face all the breaking changes we just introduced.
Personally, I prefer the first point for now. What do you think? |
Also, regarding these lines: if (typeof opt.mapOptions === "object") {
if (opt.replaceOptions === true) options = opt.mapOptions;
else $.extend(true, options, opt.mapOptions);
}$ I wonder if options = $.extend(true, {}, Mapael.defaultOptions, opt.mapOptions); What do you think? |
Hi there. I am new to mapael and btw really like the library (and have been able to impress a lot of people with it, nice work!), but I am facing this dilemma that Indigo744 mentioned about breaking changes. I was using the released version 1.1.0 up to early this week but needed the fixes for the ability to delete dynamically created links and the support for the 'all' behavior when deleting plots and links. So I switched to referencing the master version but got broken when the update signature changed. My current solution was to take a permalink of the version just before the signature change but was wondering if this is the right approach also. Would be great if breaking changes like the function signature one for example would be done on a separate branch but keep the bug fixes to existing version in master or a released branch. Bottom line is that would be great to be able to benefit from the bug fixes on the currently release but protected from breaking changes. Thanks |
To be honest, the 'all' behavior is a new feature and not a bug fix. Hence, mapael was not updated to 1.1.1 or 1.2.0. The currently supported version for production is still 1.1.0 for now. This master branch is inherently in development. Playing with a version in dev is done at your own risks! That said, you are right we should have be more careful with this, and that's why I brought up the point here. Next time we could use a specific branch. The only approach you have here is the one you said. A proper update of your software will be needed later when the new mapael version will be released. |
Hi, I'm glad you appreciate mapael ! As Indigo744 said, the master branch should be used in production at your own risk. However, I agree with you, when developping the next major versions of the plugin, a better approach will be to create a separate branch in order to be able to to maintain the current stable version with bugfixes. |
@neveldo, did you also see this comment ? #105 (comment) |
Indeed, sorry I missed this comment ! You are right, it should be You are also right regarding the download link that could be misleading, so I have changed the target to a direct download of the 1.1.0 version : http://www.vincentbroute.fr/mapael/ ( neveldo/mapael-documentation@2658ed0 ). By the way, the missing files in the documentation repository are coming soon :) |
I think we can close this issue now :-) |
This is a ticket to talk about the
event
signature.In #85, you said you wanted to clean this signature. I agree it became quite complicated and an overhaul would be good.
Before:
After:
Several questions:
deletedPlots
anddeletedLinks
could better be called to reflect what it is. LikeDeletePlotNames
andDeleteLinkNames
?The text was updated successfully, but these errors were encountered: