You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 3, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Mar 3, 2023. It is now read-only.
I think that PackageManager and Package should be resigned to be truly async and make heavy use of ES6 Promises (removing the dependency on Q). For example, package.activate() should have the option to return a Promise, and the package should not be considered "loaded" until that Promise is resolved.
Then it would be possible to depend on other packages as follows:
activate: (state) -># This package is not considered activated until the shared-logging package is activated.returnatom.packages.activate'shared-logging'
Then PackageManager and Package would have to be updated to use these Promises all the way through. For example, Package.activateNow() would have to become something like:
activateNow:->try@activateConfig()
@activateStylesheets()
if@requireMainModule()
maybePromise=@mainModule.activate(atom.packages.getPackageState(@name) ? {})
if maybePromise instanceofPromise:# or maybe just check for then() methodreturn maybePromise
elsereturnPromise.resolvenullcatch e
console.warn"Failed to activate package named '#{@name}'", e.stack
and callers of activateNow() would invoke then() on the return value, as appropriate.
I've solved package async problems in the past using process.nextTick.
This isn't good enough? Promises may be cleaner but refactoring that much
is a pain.
I think that PackageManager and Package should be resigned to be truly
async and make heavy use of ES6 Promises (removing the dependency on Q).
For example, package.activate() should have the option to return a Promise,
and the package should not be considered "loaded" until that Promise is
resolved.
Then it would be possible to depend on other packages as follows:
activate: (state) ->
# This package is not considered activated until the shared-logging package is activated.
return atom.packages.activate 'shared-logging'
Then PackageManager and Package would have to be updated to use these
Promises all the way through. For example, Package.activateNow() would
have to become something like:
activateNow: ->
try
@activateConfig()
@activateStylesheets()
if @requireMainModule()
maybePromise = @mainModule.activate(atom.packages.getPackageState(@name) ? {})
if maybePromise instanceof Promise: # or maybe just check for then() method
return maybePromise
else
return Promise.resolve null
catch e
console.warn "Failed to activate package named '#{@name}'", e.stack
and callers of activateNow() would invoke then() on the return value, as
appropriate.
—
Reply to this email directly or view it on GitHub #4059.
If activate(state) could return an arbitrary Promise, there's no guarantee that it would be resolved on the next tick (nor should it have to). For example, activate() might read from a configuration file asynchronously and do some set up based on that before it should consider itself activated.
Seems that it might improve a bit if re-done. But it does sound like a headache. IMO Better now than later, it might become even more convoluted and it might shave off some more loading time.
This issue has been automatically locked since there has not been any recent activity after it was closed. If you can still reproduce this issue in Safe Mode then please open a new issue and fill out the entire issue template to ensure that we have enough information to address your issue. Thanks!
Activity
mark-hahn commentedon Nov 4, 2014
I've solved package async problems in the past using process.nextTick.
This isn't good enough? Promises may be cleaner but refactoring that much
is a pain.
On Tue, Nov 4, 2014 at 11:08 AM, bolinfest [email protected] wrote:
bolinfest commentedon Nov 4, 2014
If
activate(state)could return an arbitraryPromise, there's no guarantee that it would be resolved on the next tick (nor should it have to). For example,activate()might read from a configuration file asynchronously and do some set up based on that before it should consider itself activated.karloluis commentedon Nov 5, 2014
Seems that it might improve a bit if re-done. But it does sound like a headache. IMO Better now than later, it might become even more convoluted and it might shave off some more loading time.
lock commentedon Apr 1, 2018
This issue has been automatically locked since there has not been any recent activity after it was closed. If you can still reproduce this issue in Safe Mode then please open a new issue and fill out the entire issue template to ensure that we have enough information to address your issue. Thanks!