Description 📖
On demand generation on change not working, but I found a workaround that does the job for now.
Reproduction/Logs 🐞📜
Hi Máximo, thanks for another awesome gem.
I'm struggling a bit with the autogeneration of types. It seems to be initializing properly, and indeed tracking changes too.
If I make a change to a serializer, and then check the output of running Rails.application.reloaders in my console, I get the following output:
<TypesFromSerializers::Changes:0x0000ffff9862ec68 @added=#<Set: {}>, @modified=#<Set: {"/app/app/typed_serializers/my_serializer.rb"}>, @removed=#<Set: {}>>
So the tracking does seem to be working, but it nothing is ever re-generated, unless I explicitly call TypesFromSerializers.generate_changed in the rails console, then it works.
So I then tried forcing it by adding another hook in my initializer:
Rails.application.reloader.to_prepare do
puts "force serializer generation"
TypesFromSerializers.generate_changed
end
But at this stage, it doesn't seem to be aware of file changes. Like this hook has a different context to my rails console. So nothing happens.
As a workaround for now I changed this hook to:
Rails.application.reloader.to_prepare do
TypesFromSerializers.generate(force: true)
end
And it works, and it's fast enough re-generating everything that it's an acceptable workaround.
So that's my issue, and I wanted to ask you if you have an idea why this may be happening? Just to mention I have also installed the listen gem.
Cheers!
bundle update types_from_serializers.Description 📖
On demand generation on change not working, but I found a workaround that does the job for now.
Reproduction/Logs 🐞📜
Hi Máximo, thanks for another awesome gem.
I'm struggling a bit with the autogeneration of types. It seems to be initializing properly, and indeed tracking changes too.
If I make a change to a serializer, and then check the output of running
Rails.application.reloadersin my console, I get the following output:So the tracking does seem to be working, but it nothing is ever re-generated, unless I explicitly call
TypesFromSerializers.generate_changedin the rails console, then it works.So I then tried forcing it by adding another hook in my initializer:
But at this stage, it doesn't seem to be aware of file changes. Like this hook has a different context to my rails console. So nothing happens.
As a workaround for now I changed this hook to:
And it works, and it's fast enough re-generating everything that it's an acceptable workaround.
So that's my issue, and I wanted to ask you if you have an idea why this may be happening? Just to mention I have also installed the
listengem.Cheers!