NoticeObserveKit icon indicating copy to clipboard operation
NoticeObserveKit copied to clipboard

Observe callback does not contain posted object, only contain userInfo.

Open lingfengmarskey opened this issue 4 years ago • 0 comments

version: 0.12

public func observe<Value: NoticeUserInfoDecodable>(name: Notice.Name<Value>,
                                                        object: Any? = nil,
                                                        queue: OperationQueue? = nil,
                                                        using: @escaping (Value) -> Void) -> Notice.Observer {
        let observer = center.addObserver(forName: name.raw, object: object, queue: queue) { notification in
            guard
                let userInfo = notification.userInfo,
                let value = Value(info: userInfo)
                else {
                    return
            }
            using(value)
        }
        return Notice.Observer(center: center, raw: observer)

Here is the implementation in pods.

received object is abandoned, can not get this from outside.

lingfengmarskey avatar Mar 18 '20 08:03 lingfengmarskey