59 likes
·
496 reads
42 comments
Love the approach, I didn't know about the StorageEvent, so I dived in (maybe to deep).
Looking into it, it seems this is exactly the intended use of the StorageEvent (developer.mozilla.org/en-US/docs/Web/API/Wi..: "it is really a way for other pages on the domain using the storage to sync any changes that are made").
--
A peculiar thing is this only works for the localStorage, even though it should work for both local and session (html.spec.whatwg.org/multipage/indices.html..).
The reason for this seems to be a catch-22, looking at the rules for the event: html.spec.whatwg.org/multipage/webstorage.h..: "Dispatches a storage event on Window objects holding an equivalent Storage object". meaning it only fires on other windows (tabs), and not the instance making the changes.
The sessionStorage has a different instance for each open window (html.spec.whatwg.org/multipage/webstorage.h..: "If the user had multiple windows opened on the site, each one would have its own individual copy of the session storage object.").
So even if the event is fired on the sessionStorage, that exact instance isn't available in any other window, so there's no instance to dispatch to. I have not looked into any actual implementation here, so I don't know exactly what happens behind the curtain.
--
Sorry for hijacking the comments, I just found it funny reading through the specs, and thought maybe others would appreciate the trivia.
Thanks for a great post!
Noice
nicely explained 💯 :D fdsfdsf fdsfsdf
Thank you Zainab! :)
Hey
@Lakshya Thakur Noice
Amazing
This might work
Testing a bunch of markdown
An h1 header
Paragraphs are separated by a blank line.
2nd paragraph. Italic, bold, and monospace
. Itemized lists look like:
this one
that one
the other one
Note that --- not considering the asterisk --- the actual text content starts at 4-columns in.
Block quotes are written like so.
They can span multiple paragraphs, if you like.
Use 3 dashes for an em-dash. Use 2 dashes for ranges (ex., "it's all in chapters 12--14"). Three dots ... will be converted to an ellipsis. Unicode is supported. ☺
An h2 header
Here's a numbered list:
first item
second item
third item
Note again how the actual text starts at 4 columns in (4 characters from the left side). Here's a code sample:
Let me re-iterate ... for i in 1 .. 10 { do-something(i) }
As you probably guessed, indented 4 spaces. By the way, instead of indenting the block, you can use delimited blocks, if you like:
define foobar() {
print "Welcome to flavor country!";
}
Great stuff
Awesome guide Ali! fsdfsdf
Useful
fsdf
nicely explained
Commenting here
Commenting here
Commenting here
Commenting here
Commenting here
awesome stufffdsfsdf
heading
trust me
truffle
- jfklsdjflkjsdlfjdslf
- jflkdsjflkdsjf
- fjlkdsjflksdjflsd
- jfsdlkjflkdsjflkdsjf
let x= 3434
let y = 324234
// fjlksdjflksjd fjksdlflk sdjflksjdflkjsd lkfjsdlkjflksdjflkjsdlkfjsdlkfjlksdjflkjsdflkjdslkfjlsdkjflksdjflkjsdlkfjsdlkjflk sdfjsdlkfjlsdkjflksdjflkjsdlf
gfdgdfg
hola
fsdf
This is good Lakshya Thakur
Lakshya Thakur Yo!f
Kavir Kaycee Yo!
Test
This is nice :)
Yohoooooooo
Good One
Great!
Hey there
interesting one
all new comment