YYTransaction.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //
  2. // YYTransaction.h
  3. // YYKit <https://github.com/ibireme/YYKit>
  4. //
  5. // Created by ibireme on 15/4/18.
  6. // Copyright (c) 2015 ibireme.
  7. //
  8. // This source code is licensed under the MIT-style license found in the
  9. // LICENSE file in the root directory of this source tree.
  10. //
  11. #import <Foundation/Foundation.h>
  12. NS_ASSUME_NONNULL_BEGIN
  13. /**
  14. YYTransaction let you perform a selector once before current runloop sleep.
  15. */
  16. @interface YYTransaction : NSObject
  17. /**
  18. Creates and returns a transaction with a specified target and selector.
  19. @param target A specified target, the target is retained until runloop end.
  20. @param selector A selector for target.
  21. @return A new transaction, or nil if an error occurs.
  22. */
  23. + (YYTransaction *)transactionWithTarget:(id)target selector:(SEL)selector;
  24. /**
  25. Commit the trancaction to main runloop.
  26. @discussion It will perform the selector on the target once before main runloop's
  27. current loop sleep. If the same transaction (same target and same selector) has
  28. already commit to runloop in this loop, this method do nothing.
  29. */
  30. - (void)commit;
  31. @end
  32. NS_ASSUME_NONNULL_END