Flow_Browser/PrivateBrowser/Pods/PromiseKit/Extensions/Foundation/Sources/NSNotificationCenter+AnyPromise.h
2024-04-17 14:43:19 +08:00

45 lines
1.3 KiB
Objective-C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#import <Foundation/NSNotification.h>
#import <PromiseKit/AnyPromise.h>
/**
To import the `NSNotificationCenter` category:
use_frameworks!
pod "PromiseKit/Foundation"
Or `NSNotificationCenter` is one of the categories imported by the umbrella pod:
use_frameworks!
pod "PromiseKit"
And then in your sources:
#import <PromiseKit/PromiseKit.h>
*/
@interface NSNotificationCenter (PromiseKit)
/**
Observe the named notification once.
[NSNotificationCenter once:UIKeyboardWillShowNotification].then(^(id note, id userInfo){
UIViewAnimationCurve curve = [userInfo[UIKeyboardAnimationCurveUserInfoKey] integerValue];
CGFloat duration = [userInfo[UIKeyboardAnimationDurationUserInfoKey] floatValue];
return [UIView promiseWithDuration:duration delay:0.0 options:(curve << 16) animations:^{
}];
});
@warning *Important* Promises only resolve once. If you need your block to execute more than once then use `-addObserverForName:object:queue:usingBlock:`.
@param notificationName The name of the notification for which to register the observer.
@return A promise that fulfills with two parameters:
1. The NSNotification object.
2. The NSNotifications userInfo property.
*/
+ (AnyPromise *)once:(NSString *)notificationName NS_REFINED_FOR_SWIFT;
@end