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

Add bind this example for eventBus in plugins #8668

Closed
3 tasks done
WingDr opened this issue Jul 3, 2023 · 1 comment
Closed
3 tasks done

Add bind this example for eventBus in plugins #8668

WingDr opened this issue Jul 3, 2023 · 1 comment
Assignees
Milestone

Comments

@WingDr
Copy link

WingDr commented Jul 3, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Can the issue be reproduced with the default theme (daylight/midnight)?

  • I was able to reproduce the issue with the default theme

Could the issue be due to extensions?

  • I've ruled out the possibility that the extension is causing the problem.

Describe the problem

在点击触发的三个 eventBus 上都试了一下,先打印的是event,然后打印的是this,我不知道这算js的特性还是程序bug,并且没有找到相关的issue,所以我先提一下

image

Expected result

this应该是指向这个函数所在类的

Screenshot or screen recording presentation

No response

Version environment

- Version: 2.9.3
- Operating System: windows 
- Browser (if used):

Log file

I 2023/07/03 22:03:14 box.go:79: auto stat [trees=275, blocks=13238, dataSize=210 MB, assetsSize=24 MB]
I 2023/07/03 22:03:14 disk.go:33: disk usage [total=785 GB, used=233 GB, free=552 GB]
I 2023/07/03 22:07:27 repository.go:1182: synced data repo [kernel=xy62sf2, provider=0, ufc=4, dfc=1, ucc=2, dcc=0, ub=163 kB, db=72 kB] in [1.89s]

More information

No response

Vanessa219 added a commit to siyuan-note/plugin-sample that referenced this issue Jul 5, 2023
@Vanessa219
Copy link
Member

Vanessa219 commented Jul 5, 2023

JS 中的 this 在 EventBus 中就是这样的。需要使用 this 可参考 7cfba4ae27fd3bddf82c2d9cc9a512a94c898ae3 中的更改。

@Vanessa219 Vanessa219 self-assigned this Jul 5, 2023
@Vanessa219 Vanessa219 changed the title Losing "this" in eventBus triggering Add bind this example for eventBus in plugins Jul 5, 2023
@Vanessa219 Vanessa219 changed the title Add bind this example for eventBus in plugins Add bind this example for eventBus in plugins Jul 5, 2023
@Vanessa219 Vanessa219 added this to the 2.9.5 milestone Jul 5, 2023
Vanessa219 added a commit to siyuan-note/plugin-sample that referenced this issue Jul 5, 2023
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

2 participants