Added a "userInfo" property to relevant types to allow external code to store custom data

This commit is contained in:
John Estropia
2017-04-20 16:40:27 +09:00
parent fd14a18248
commit a543a4c94a
6 changed files with 160 additions and 114 deletions

View File

@@ -110,6 +110,21 @@ public final class ObjectMonitor<D: DynamicObject>: Equatable {
}
// MARK: Public (3rd Party Utilities)
/**
Allow external libraries to store custom data in the `ObjectMonitor`. App code should rarely have a need for this.
```
enum Static {
static var myDataKey: Void?
}
monitor.userInfo[&Static.myDataKey] = myObject
```
- Important: Do not use this method to store thread-sensitive data.
*/
private let userInfo = UserInfo()
// MARK: Equatable
public static func == (lhs: ObjectMonitor<ObjectType>, rhs: ObjectMonitor<ObjectType>) -> Bool {