Skip to content

Releases: github/session-resume

v0.5.2

18 Oct 00:37
78ce055
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v0.5.1...v0.5.2

v0.5.1

09 Jul 18:16
4936109
Compare
Choose a tag to compare

What's Changed

Full Changelog: v0.5.0...v0.5.1

v0.5.0

08 Feb 20:38
7b4243a
Compare
Choose a tag to compare

What's Changed

New Contributors

  • @helen made their first contribution in #30

Full Changelog: v0.4.0...v0.5.0

v0.4.0

24 Jan 20:46
cee83c0
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v0.3.1...v0.4.0

v0.3.1

20 Oct 19:11
1236700
Compare
Choose a tag to compare

What's Changed

  • Make sure to access sessionStorage in a try block by @Bestra in #39

Full Changelog: v0.3.0...v0.3.1

v0.3.0

13 Oct 15:25
e2d3656
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v0.2.0...v0.3.0

v0.2.0

23 Apr 10:04
v0.2.0
7e40603
Compare
Choose a tag to compare

Session Resume now persists fields that are not immediately present in the DOM. (#16) Thank you @jklina 🎉

0.1.0

10 Apr 22:14
v0.1.0
Compare
Choose a tag to compare
  • Replace Babel + Flow with TypeScript #13

v0.0.7

05 Aug 15:04
a99e4a4
Compare
Choose a tag to compare
  • Merge pull request #10 from github/fix-gpr-publish d24f7d3
  • dont run scripts when publishing to GPR aa5bd56

0.0.6...v0.0.7

0.0.7

05 Aug 15:04
d24f7d3
Compare
Choose a tag to compare

Session Resume

Annotate fields to be persisted on navigation away from the current page.
Fields be automatically restored when the user revists the page again in
their current browser session (excludes separate tabs).

Not design for persisted crash recovery.

Installation

$ npm install @github/session-resume

Usage

HTML

<form>
  <input id="new-comment" class="js-session-resumable"/>
</form>

JS

import {persistResumableFields, restoreResumableFields, setForm} from '@github/session-resume'

function getPageID() {
  return window.location.pathname
}

// Listen for all form submit events and to see if their default submission
// behavior is invoked.
window.addEventListener('submit', setForm, {capture: true})

// Resume field content on regular page loads.
window.addEventListener('pageshow', function() {
  restoreResumableFields(getPageID())
})

// Persist resumable fields when page is unloaded
window.addEventListener('pagehide', function() {
  persistResumableFields(getPageID())
})

Development

npm install
npm test

License

Distributed under the MIT license. See LICENSE for details.