GithubHelp home page GithubHelp logo

glpubsub's People

Contributors

allenhsu avatar ltebean avatar tomliu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

glpubsub's Issues

subscribe UIKeyboardWillShowNotification 无法从 GLEvent 中获取键盘信息

id observer =  [[NSNotificationCenter defaultCenter] addObserverForName:eventName object:obj queue:_pubSubQueue usingBlock:^(NSNotification *note) {
    GLEvent *event = [[GLEvent alloc] initWithName:eventName obj:note.object data:[note.userInfo objectForKey:kGLPubSubDataKey]];
    handler(event);
}];

data 只存了 userInfo 里面 key 为 kGLPubSubDataKey 的值,这样会忽略掉一些系统 Notification 的 userInfo,是不是不合理?

为什么用 set 存储 observer

在下面的方法中:

- (id)subscribe:(NSString *)eventName obj:(id)obj handler:(GLEventHandler)handler {

使用 NSMutableDictionary 存储了事件对应的 observers, 使用 nsset 存储了observer。

比较好奇的是为什么不直接用 NSMutableDictionary 而套了一层 set ?谢谢

修改 GLEventHandler

团队里有很多人,总有某些原因,或者没注意到,或是忘记了,或者懒,在 block 里强引用了 self。
所以我修改了 GLEventHandler,在 block 也可以放心使用 self,不必写那些烦人的 weakSelf。

typedef void (^GLEventHandler)(id self, GLEvent *event);

在调用 handler 时,self 弱引用 self(第一个 self 和 第二 self)并不是同一个东西,
那么在 block 的作用域内,self 都是弱引用的了,只是访问属性 要用 getter 和 setter 方法了。

自动移除订阅

在使用GLPubSub时,如果类A通过block订阅一个通知后,如果不在dealloc方法移除,这个block将会一直存在;这样将会导致对象被释放,当有对应的通知时还是会执行block,那么就必须在dealloc方法中调用,该操作是否可以放在GLPubSub中进行统一处理呢?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.