Working with macros (e.g. Observable) #99
Replies: 3 comments 2 replies
-
| 
         A workaround can be doing something like this: @Observable
final class MarvelHeroesViewModel {
	var superHeroes: [MarvelCharacter] = []
	var isLoading = false
	let marvelHeroesService: MarvelHeroesService
	init() {
		@Dependency(\.marvelHeroesService) var marvelHeroesService
		self.marvelHeroesService = marvelHeroesService
		self.loadData()
	}
 | 
  
Beta Was this translation helpful? Give feedback.
-
| 
         Hi @hadiidbouk, there are two things happening here: one is definitely a bug and the other is a limitation of  The bug is that property wrappers currently do not work in  @Observable 
class Library: ObservableObject {
  @Published var books: [Book] = [Book(), Book(), Book ()]
}And the limitation is that  However, even with the bug and limitation it is still possible to use  @Observable
class Model {
  @ObservationIgnored @Dependency(\.date) var date
}That compiles just fine.  | 
  
Beta Was this translation helpful? Give feedback.
-
| 
         Requiring a default value is a known bug (link). So, it should work properly after that is fixed?  | 
  
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
With the introduction of
macrosand especially@Observable, the library seems incompatible with theObservableMacro, and we need to provide an initial value of our dependencies.Any thoughts on how we can support the
ObservableMacro? Should we convert the property wrapper to amacro?Beta Was this translation helpful? Give feedback.
All reactions