You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// A macro that adds ``Publishable-protocol`` conformance to `Observable` types.
12
+
///
13
+
/// - Note: This macro works only with `final` classes to which the `Observable` or `SwiftData.Model` macro has been applied directly.
14
+
///
15
+
/// The `Publishable` macro adds a new ``Publishable/publisher`` property to your type,
16
+
/// which exposes `Combine` publishers for all mutable instance properties - both stored and computed.
17
+
///
18
+
/// If a property’s type conforms to `Equatable`, its publisher automatically removes duplicate values.
19
+
/// Just like the `Published` property wrapper, subscribing to any of the exposed publishers immediately emits the current value.
20
+
///
21
+
/// - Important: Swift Macros do not have access to full type information of expressions used in the code they’re applied to.
22
+
/// Since working with `Combine` requires knowledge of concrete types, this macro attempts to infer the types of properties when they are not explicitly specified.
23
+
/// However, this inference may fail in non-trivial cases. If the generated code fails to compile, explicitly specifying the type of the affected property should resolve the issue.
24
+
///
9
25
@attached(
10
26
member,
11
27
names:named(_publisher),
@@ -22,9 +38,22 @@ public macro Publishable() = #externalMacro(
22
38
type:"PublishableMacro"
23
39
)
24
40
25
-
publicprotocolPublishable:AnyObject{
41
+
/// A type that can be observed using both the `Observation` and `Combine` frameworks.
42
+
///
43
+
/// You don't need to declare conformance to this protocol yourself.
44
+
/// It is generated automatically when you apply the ``Publishable()`` macro to your type.
45
+
///
46
+
publicprotocolPublishable:AnyObject,Observable{
26
47
48
+
/// A subclass of ``AnyPropertyPublisher`` generated by the ``Publishable()`` macro,
49
+
/// containing publishers for all mutable instance properties of the type.
0 commit comments