DEV Community

Discussion on: React Context pattern in Rails

 
thevtm profile image
Vinícius Manjabosco

I agree that request_store_rails would be an alternative solution for my problems.

Maybe I'm missing something but the with block is the "clean up mechanism".

    def with(request_value)
      if get.present?
        raise ContextAlreadyDefinedError,
          "Context already defined!"
      end

      begin
        @@request_value.value = request_value
        yield
      ensure
        @@request_value.value = nil # "clean up mechanism"
      end
    end
Enter fullscreen mode Exit fullscreen mode
Thread Thread
 
silva96 profile image
Benjamín Silva

totally, my bad!