Class: React::Component::History

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

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



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

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

Instance Method Details

#block(prompt) ⇒ Object



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

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

#create_href(location) ⇒ Object



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

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

#go(n) ⇒ Object



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

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

#go_backObject



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

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

#go_forwardObject



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

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

#listen(&block) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/react/component/history.rb', line 38

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



50
51
52
53
54
55
56
57
58
# File 'lib/react/component/history.rb', line 50

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



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

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

#replace(*args) ⇒ Object



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

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

#to_nObject



60
61
62
# File 'lib/react/component/history.rb', line 60

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