Skip to content

Commit

Permalink
Code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
cedx committed Aug 30, 2024
1 parent 63a449d commit fc3badc
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/webstorage/Storage.hx
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,14 @@ class Storage {
/** Creates a new storage service. **/
function new(backend: DomStorage, ?options: StorageOptions) {
var onChange = onChangeTrigger.asSignal();
if (options?.listenToGlobalEvents ?? false) {
final signal = Signal
.ofClassical(window.addEventListener.bind("storage"), window.removeEventListener.bind("storage"))
.filter((event: DomStorageEvent) -> event.storageArea == backend && (event.key == null || event.key.startsWith(keyPrefix)))
.map(event -> new StorageEvent(
event.key == null ? None : Some(event.key.substr(keyPrefix.length)),
event.oldValue == null ? None : Some(event.oldValue),
event.newValue == null ? None : Some(event.newValue)
));

onChange = onChange.join(signal);
}
if (options?.listenToGlobalEvents ?? false) onChange = onChange.join(Signal
.ofClassical(window.addEventListener.bind("storage"), window.removeEventListener.bind("storage"))
.filter((event: DomStorageEvent) -> event.storageArea == backend && (event.key == null || event.key.startsWith(keyPrefix)))
.map(event -> new StorageEvent(
event.key == null ? None : Some(event.key.substr(keyPrefix.length)),
event.oldValue == null ? None : Some(event.oldValue),
event.newValue == null ? None : Some(event.newValue)
)));

this.backend = backend;
this.onChange = onChange;
Expand Down

0 comments on commit fc3badc

Please sign in to comment.