Sha256: c822f5d2c3ef9a357284f81ba3284affd317eab2baeecd42f1fb75cb6fdc5ca3

Contents?: true

Size: 1.6 KB

Versions: 31

Compression:

Stored size: 1.6 KB

Contents

module React
  module Component
    class History
      include ::Native::Wrapper

      def block(prompt)
        @native.JS[:props].JS[:history].JS.block(prompt)
      end

      def create_href(location)
        @native.JS[:props].JS[:history].JS.createHref(location)
      end

      def go(n)
        @native.JS[:props].JS[:history].JS.go(n)
      end

      def go_back
        @native.JS[:props].JS[:history].JS.goBack()
      end

      def go_forward
        @native.JS[:props].JS[:history].JS.goForward()
      end

      def push(*args)
        @native.JS[:props].JS[:history].JS.push(*args)
      end

      def replace(*args)
        @native.JS[:props].JS[:history].JS.replace(*args)
      end

      def method_missing(prop, *args, &block)
        @native.JS[:props].JS[:history].JS[prop]
      end

      def listen(&block)
        fun = nil
        %x{
          fun = function(location, action) {
            let ruby_location = #{React::Component::Location.new(`{ props: { location: location }}`)}
            block.$call(ruby_location, action);
          }
        }
        unlisten = @native.JS[:props].JS[:history].JS.listen(fun)
        -> { unlisten.JS.call() }
      end

      def location
        return @location if @location
        return nil unless @native.JS[:props].JS[:history].JS[:location]
        if @native.JS[:props].JS[:history].JS[:location].JS[:pathname]
          @location = React::Component::Location.new(@native)
        else
          @native.JS[:props].JS[:history].JS[:location]
        end
      end

      def to_n
        @native.JS[:props].JS[:history]
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
isomorfeus-react-16.13.11 lib/react/component/history.rb
isomorfeus-react-16.13.10 lib/react/component/history.rb
isomorfeus-react-16.13.9 lib/react/component/history.rb
isomorfeus-react-16.13.8 lib/react/component/history.rb
isomorfeus-react-16.13.7 lib/react/component/history.rb
isomorfeus-react-16.13.6 lib/react/component/history.rb
isomorfeus-react-16.13.5 lib/react/component/history.rb
isomorfeus-react-16.13.4 lib/react/component/history.rb
isomorfeus-react-16.13.3 lib/react/component/history.rb
isomorfeus-react-16.13.2 lib/react/component/history.rb
isomorfeus-react-16.13.1 lib/react/component/history.rb
isomorfeus-react-16.13.0 lib/react/component/history.rb
isomorfeus-react-16.12.24 lib/react/component/history.rb
isomorfeus-react-16.12.23 lib/react/component/history.rb
isomorfeus-react-16.12.22 lib/react/component/history.rb
isomorfeus-react-16.12.21 lib/react/component/history.rb
isomorfeus-react-16.12.20 lib/react/component/history.rb
isomorfeus-react-16.12.19 lib/react/component/history.rb
isomorfeus-react-16.12.18 lib/react/component/history.rb
isomorfeus-react-16.12.17 lib/react/component/history.rb