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

Re-order taps after tap function is called to guarantee old taps are in correct order #135

Open
soc221b opened this issue Sep 12, 2020 · 3 comments

Comments

@soc221b
Copy link

soc221b commented Sep 12, 2020

Suppose we have two plugins to be tapped:

The following example is WRONG. Please see this comment

hook.tap({
  name: 'a',
  before: 'b'
}, () => {})

hook.tap({
  name: 'b',
}, () => {})

Actual: taps are [{ name: 'b', ... }, { name: 'a', ... }].
Expected: taps should be [{ name: 'a', ...}, { name: 'b', ... }].

@alexander-akait
Copy link
Member

You need tap b before tapping a

@sokra
Copy link
Member

sokra commented Sep 14, 2020

hook.tap({
  name: 'a',
  before: 'b'
}, () => {
    console.log("a");
})

hook.tap({
  name: 'b',
}, () => {
    console.log("b");
})

hook.call();
a
b

Working as expected for me

@sokra sokra closed this as completed Sep 14, 2020
@sokra sokra reopened this Sep 14, 2020
@soc221b
Copy link
Author

soc221b commented Sep 14, 2020

Take another example:

hook.tap({
  name: 'a',
  before: 'b',
}, () => {
  console.log('a')
})

hook.tap({
  name: 'b',
  before: 'c',
}, () => console.log('b'))

hook.tap('c', () => console.log('c'))

hook.call()

// b
// a
// c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants