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

一次监听 移除observer匹配 仅保留name区别 #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions WxNotificationCenter/WxNotificationCenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,18 @@ function addNotification(name, selector, observer) {
* name: 注册名,一般let在公共类中
* selector: 对应的通知方法,接受到通知后进行的动作
* observer: 注册对象,指Page对象
* 备注: 不同监听使用不同的name
*/
function addOnceNotification(name, selector, observer) {
if (__notices.length > 0) {
for (var i = 0; i < __notices.length; i++) {
var notice = __notices[i];
if (notice.name === name) {
if (notice.observer === observer) {
return;
}
return;
}
}
this.addNotification(name, selector, observer)
}
this.addNotification(name, selector, observer)
}

function addNotices(newNotice) {
Expand Down