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

Move away from cockpit.defer() #21266

Open
2 tasks
jelly opened this issue Nov 14, 2024 · 0 comments
Open
2 tasks

Move away from cockpit.defer() #21266

jelly opened this issue Nov 14, 2024 · 0 comments

Comments

@jelly
Copy link
Member

jelly commented Nov 14, 2024

This is our non-standard Promise API which doesn't map correctly to the Promise API.

Deferred API

  • .fail()
  • .done()
  • .always()

These are non-standard and still used in our code base and could in theory be replaced?

  • .done() to port to .then()

  • .fail() replace with .catch()?

  • .always() is called when the promise is resolved or rejected, can be replaced with .finally()?

  • .progress()

  • .stream()

  • .input()

These deferred promise functions cannot be mapped to the Promise api and needs to be re-designed.

File API

  • cockpit.file.read().then returns a promise with multiple values this is non-standard

The rest of cockpit.file() can be ported to modern promises.

Cockpit Spawn

Uses defer() for .input() and .stream()

There is a resolve() with two arguments in the close eventlistener which can't be done with the Promise API

cockpit.http()

The API supports .stream() and .input() which cannot be done with a native Promise.

Stop using cockpit.defer in our pages

Port all our usage in pages away from cockpit.defer and keep using it internally in cockpit. Two pages needs to be ported for this to happen:

  • pkg/lib/journal.js
  • pkg/lib/cockpit-components-install-dialog.jsx
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

1 participant