Repository navigation
Conversation
|
I've started with refactoring of the I'll next refactor The specs have only changed in terms of execution, but not in expectations. In a few cases specs are simplified by moving expectations to the place it actually should be tested. I've also started to add documentation and specs for functions old and new to make clearer what goes on and how things are expected to behave. |
Yes, but no I have no idea why it happens and actually thought it was a Windows-only issue. |
# Conflicts: # lib/atom-io-client.coffee # lib/package-card.coffee # lib/package-detail-view.coffee
|
Just wanted to give you an update this PR. Note: It has become a big one, in case you feel that it should be split up into separate ones let me know.
For caching avatars there is now a
I have added documentation to all new public functions as well as specs. I'll add more as I go on, so future contributors find there way around easier. Currently a few specs fail, which I'll fix in the coming week. I also have a hunch on why The functionality remains the same, you should see some minor improvements in performance. There are a few quirks still, which I'll iron out and have tests for them. |
|
Since this has become a pretty huge refactor I have become more and more worried and uncomfortable to have it merged. |
|
That's often the case with big refactorings :( Loop me in when you start each individual piece and I'll try and be your merge buddy. |
|
@damieng yeah, I'll split them up into more logical changes and smaller packages and push them over time as PRs. The refactoring itself was a piece of cake, but keeping up with maintaining the specs and keeping adjusting there setup stages was a hassle, since Anyways. All of this did help me to get a detailed picture of literally all code and taking one bite at a time is going to be much easier. :) |

This a proposal to introduce a
Packagemodel, refactorPackageManagerand address performance issues, makeAtomIoClientobsolete and refactor components to usePackagemodel and refactoredPackageManager.Introduce Package model
Currently
PackageManagerandPackageCardhold a number of functions that would be better in the context of a model. Things like installing, updating, uninstalling as well as checking various states of a package should be handled by the model and emit events that other components can rely on. It takes also responsibility to maintain it's avatar in the cache on disk. It will also listen to changes of it's cache item and emit an update event.Refactor PackageManager
There is a lot of code that can be refactored. The result of the refactor will be unified promised command execution, consistent package information cache, return
Packagemodel instances instead of bare objects and, last but not least, expose command errors as notifications instead of swallowing them inconsoleif it is caused by a user triggered action.With moving to promised execution of
apmcommands we can reduce the confusion of multiple callbacks inter-mingling and make more clear what's going on. Execution of commands should also respectnavigator.onlineand be prevented commands requiring network access from happening when offline.PackageManagerandAtomIoClientare caching package information in three different ways, asavailablePackageCache,apmCacheandlocalStorage. The latter should be the only place to cache. It will keep a cached JSON string for each package.For installed, featured and outdated it will keep package-names in arrays. Installed package arrays will be split up by subkeys for core, user, dev and git, featured lists by subkeys for themes and packages.
The lists will be created when the cache is first initialised, updated asynchronously and emit events when they are changed, essentially moving in the
Listfunctionality or incorporating it.ListViewscan listen for them and update appropriately,PackageManagerwill use them also to update package information cached.Refactor components to use
Packagemodel and refactoredPackageManagerPackageCardwill be refactored to rely on thePackageas well as the refactoredPackageManager. The panels "Packages", "Themes", "Updates" and "Install" will also be affected by this, but only in regards to retrieving packages.Main objective
The goal besides improving code and make it more readable, is to make the panels interacting with packages more responsive, by showing package lists and information when cached immediately and only update when changed by updates performed asynchronously.
Related issues
Todos
PackageManager#commandlocalStoragecache inPackageMangerPackageManager#getListwith a list-key as an argument, returning an Object or Array with package namesPackageManager#getListOfPackagescalling#getListand map package names toPackageinstancesNote: I'll update related issues and todos over the course of the PR