Class: Turbo::Session

Inherits:
Object
  • Object
show all
Includes:
NavigationDelegateMethods, SessionDelegateMethods, VisitDelegateMethods, VisitableDelegateMethods, WebViewDelegateMethods
Defined in:
lib/turbo/session/session.rb,
lib/turbo/session/visit_delegate_methods.rb,
lib/turbo/session/session_delegate_methods.rb,
lib/turbo/session/web_view_delegate_methods.rb,
lib/turbo/session/visitable_delegate_methods.rb,
lib/turbo/session/navigation_delegate_methods.rb

Overview

A Session represents the main interface for managing a Turbo app in a web view. Each Session manages a single web view so you should create multiple sessions to have multiple web views, for example when using modals or tabs

Defined Under Namespace

Modules: NavigationDelegateMethods, SessionDelegateMethods, VisitDelegateMethods, VisitableDelegateMethods, WebViewDelegateMethods

Instance Attribute Summary collapse

Attributes included from NavigationDelegateMethods

#navigationAction

Instance Method Summary collapse

Methods included from NavigationDelegateMethods

#externallyOpenableURL, #isMainFrameNavigation, #policy, #shouldOpenURLExternally, #shouldReloadPage

Methods included from SessionDelegateMethods

#session, #sessionDidFinishFormSubmission, #sessionDidFinishRequest, #sessionDidLoadWebView, #sessionDidStartFormSubmission, #sessionDidStartRequest

Methods included from WebViewDelegateMethods

#webViewDidInvalidatePage

Methods included from VisitableDelegateMethods

#visitableDidRequestRefresh, #visitableDidRequestReload, #visitableViewDidAppear, #visitableViewWillAppear

Methods included from VisitDelegateMethods

#visit, #visitDidComplete, #visitDidFail, #visitDidFinish, #visitDidInitializeWebView, #visitDidRender, #visitDidStart, #visitRequestDidFinish, #visitRequestDidStart, #visitWillLoadResponse, #visitWillStart

Instance Attribute Details

#activatedVisitableObject (readonly)

Returns the value of attribute activatedVisitable.



14
15
16
# File 'lib/turbo/session/session.rb', line 14

def activatedVisitable
  @activatedVisitable
end

#bridge=(value) ⇒ Object

Sets the attribute bridge

Parameters:

  • value

    the value to set the attribute bridge to.



13
14
15
# File 'lib/turbo/session/session.rb', line 13

def bridge=(value)
  @bridge = value
end

#currentVisitObject (readonly)

Returns the value of attribute currentVisit.



14
15
16
# File 'lib/turbo/session/session.rb', line 14

def currentVisit
  @currentVisit
end

#delegateObject

Returns the value of attribute delegate.



13
14
15
# File 'lib/turbo/session/session.rb', line 13

def delegate
  @delegate
end

#initializedObject (readonly)

Returns the value of attribute initialized.



14
15
16
# File 'lib/turbo/session/session.rb', line 14

def initialized
  @initialized
end

#pathConfigurationObject

Returns the value of attribute pathConfiguration.



13
14
15
# File 'lib/turbo/session/session.rb', line 13

def pathConfiguration
  @pathConfiguration
end

#refreshingObject (readonly)

Returns the value of attribute refreshing.



14
15
16
# File 'lib/turbo/session/session.rb', line 14

def refreshing
  @refreshing
end

#topmostVisitObject (readonly)

Returns the value of attribute topmostVisit.



14
15
16
# File 'lib/turbo/session/session.rb', line 14

def topmostVisit
  @topmostVisit
end

#topmostVisitableObject (readonly)

The topmost visitable is the visitable that has most recently completed a visit



56
57
58
# File 'lib/turbo/session/session.rb', line 56

def topmostVisitable
  @topmostVisitable
end

#webViewObject

Returns the value of attribute webView.



13
14
15
# File 'lib/turbo/session/session.rb', line 13

def webView
  @webView
end

Instance Method Details

#activeVisitableObject

The active visitable is the visitable that currently owns the web view



61
62
63
# File 'lib/turbo/session/session.rb', line 61

def activeVisitable
  activatedVisitable
end

#clearSnapshotCacheObject



113
114
115
# File 'lib/turbo/session/session.rb', line 113

def clearSnapshotCache
  bridge.clearSnapshotCache
end

#initObject



21
22
23
# File 'lib/turbo/session/session.rb', line 21

def init
  initWithConfiguration(WKWebViewConfiguration.alloc.init)
end

#initWithConfiguration(configuration) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/turbo/session/session.rb', line 25

def initWithConfiguration(configuration)
  webViewConfiguration = configuration
  webView = WKWebView.alloc.initWithFrame(CGRectZero, configuration: webViewConfiguration)
  webView.layer.borderColor = UIColor.blueColor
  webView.layer.borderWidth = 2

  initWithWebView(webView)
end

#initWithWebView(webView) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/turbo/session/session.rb', line 34

def initWithWebView(webView)
  @webView = webView
  @initialized = false
  @refreshing = false
  setup
  self
end

#makeVisit(visitable, options: options) ⇒ Object



97
98
99
100
101
102
103
104
# File 'lib/turbo/session/session.rb', line 97

def makeVisit(visitable, options: options)
  if initialized
    restorationIdentifier = restorationIdentifierForVisitable(visitable)
    JavaScriptVisit.alloc.initWithVisitable(visitable, options: options, bridge: bridge, restorationIdentifier: restorationIdentifier)
  else
    ColdBootVisit.alloc.initWithVisitable(visitable, options: options, bridge: bridge)
  end
end

#reloadObject



106
107
108
109
110
111
# File 'lib/turbo/session/session.rb', line 106

def reload
  return unless visitable = topmostVisitable
  @initialized = false
  visitVisitable(visitable)
  @topmostVisit = currentVisit
end

#visitVisitable(visitable, options: options, reload: reload) ⇒ Object



65
66
67
# File 'lib/turbo/session/session.rb', line 65

def visitVisitable(visitable)
  visitVisitable(visitable, options: nil)
end