Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import session instead of reading window.Turbo.session #1094

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ import { PageRenderer } from "./drive/page_renderer"
import { PageSnapshot } from "./drive/page_snapshot"
import { FrameRenderer } from "./frames/frame_renderer"
import { FormSubmission } from "./drive/form_submission"
import { StreamActions } from "./streams/stream_actions"
import { fetch, recentRequests } from "../http/fetch"

const session = new Session(recentRequests)
const { cache, navigator } = session
export { navigator, session, cache, PageRenderer, PageSnapshot, FrameRenderer, StreamActions, fetch }
export { navigator, session, cache, PageRenderer, PageSnapshot, FrameRenderer, fetch }

/**
* Starts the main session.
Expand Down
4 changes: 3 additions & 1 deletion src/core/streams/stream_actions.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { session } from "../"

export const StreamActions = {
after() {
this.targetElements.forEach((e) => e.parentElement?.insertBefore(this.templateContent, e.nextSibling))
Expand Down Expand Up @@ -33,6 +35,6 @@ export const StreamActions = {
},

refresh() {
window.Turbo.session.refresh(this.baseURI, this.requestId)
session.refresh(this.baseURI, this.requestId)
}
}
4 changes: 3 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import "./polyfills"
import "./elements"
import "./script_warning"
import { StreamActions } from "./core/streams/stream_actions"

import * as Turbo from "./core"

window.Turbo = Turbo
window.Turbo = { ...Turbo, StreamActions }
Turbo.start()

export { StreamActions }
export * from "./core"
export * from "./elements"
export * from "./http"