Class: React::Component::History

Inherits:
Object
  • Object
show all
Includes:
Native::Wrapper
Defined in:
lib/react/component/history.rb

Instance Method Summary collapse

Constructor Details

#initialize(native) ⇒ History

Returns a new instance of History.



6
7
8
# File 'lib/react/component/history.rb', line 6

def initialize(native)
  @native = native
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(prop, *args, &block) ⇒ Object



38
39
40
# File 'lib/react/component/history.rb', line 38

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

Instance Method Details

#block(prompt) ⇒ Object



10
11
12
# File 'lib/react/component/history.rb', line 10

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

#create_href(location) ⇒ Object



14
15
16
# File 'lib/react/component/history.rb', line 14

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

#go(n) ⇒ Object



18
19
20
# File 'lib/react/component/history.rb', line 18

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

#go_backObject



22
23
24
# File 'lib/react/component/history.rb', line 22

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

#go_forwardObject



26
27
28
# File 'lib/react/component/history.rb', line 26

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

#listen(&block) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/react/component/history.rb', line 42

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

#locationObject



54
55
56
57
58
59
60
61
62
# File 'lib/react/component/history.rb', line 54

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

#push(*args) ⇒ Object



30
31
32
# File 'lib/react/component/history.rb', line 30

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

#replace(*args) ⇒ Object



34
35
36
# File 'lib/react/component/history.rb', line 34

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

#to_nObject



64
65
66
# File 'lib/react/component/history.rb', line 64

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