Skip to content

AndroidEventBus的优化建议 #48

@xiaweicheng

Description

@xiaweicheng

(1)EventBus里面的handleStickyEvent方法最后执行的判断条件冗余,因为通过foundEventType找到的subscription其eventType一定和foundType相等。所以判断条件只需要isTarget(subItem, subscriber)即可

(2)经过第一步之后,Subscription里面的EventType就没有被用到,可以去掉了。因为EventType在mSubscribeMap是Key的角色,Subscription本质是value的角色,value里面含有key很奇怪

(3)TargetMethod这个类,感觉有点冗余,这个类只在SubscribeMethodHunter里面使用,它从findSubcribeMethods(...)方法里面接收Method , EventType type, ThreadMode 参数,然后传递给subscibe(EventType event, TargetMethod method, Object subscriber)使用,建议把subscribe(...)方法改成 private void subscibe(EventType event, Object subscriber, Method method, ThreadMode threadMode) ,这样TargetMethod这个类也可以优化掉。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions