Skip to content

Commit

Permalink
0.0.880
Browse files Browse the repository at this point in the history
  • Loading branch information
bahrus committed Feb 4, 2025
1 parent 34d01dd commit 36a73bc
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 70 deletions.
42 changes: 9 additions & 33 deletions froop/O.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { assignGingerly } from '../lib/assignGingerly.js';
import { RRMixin } from './RRMixin.js';
const publicPrivateStore = Symbol();
export class O extends HTMLElement {
export class O extends RRMixin(HTMLElement) {
propagator = new EventTarget();
[publicPrivateStore] = {};
async covertAssignment(obj) {
Expand All @@ -23,42 +24,16 @@ export class O extends HTMLElement {
}
await assignGingerly(this[publicPrivateStore], extObj);
}
#disconnectedAbortController;
get disconnectedSignal() {
return this.#disconnectedAbortController.signal;
}
// #disconnectedAbortController: AbortController;
// get disconnectedSignal(){
// return this.#disconnectedAbortController.signal;
// }
constructor() {
super();
const internals = this.attachInternals();
this.#internals = internals;
this.copyInternals(internals);
this.#disconnectedAbortController = new AbortController();
}
sleep;
awake() {
return new Promise((resolve, reject) => {
if (!this.sleep) {
resolve();
return;
}
const ac = new AbortController();
//I'm thinking this one isn't worth wrapping in an EventHandler, as the "closure"
//isn't accessing anything other than the resolve and abort controller, doesn't seem worth it.
this.propagator.addEventListener('sleep', e => {
if (!this.sleep) {
ac.abort();
resolve();
}
}, { signal: ac.signal });
});
}
nudge() {
const { sleep } = this;
this.sleep = sleep ? sleep - 1 : 0;
}
rock() {
const { sleep } = this;
this.sleep = sleep === undefined ? 1 : sleep + 1;
//this.#disconnectedAbortController = new AbortController();
}
/**
* Keep internals reference private, but allow subclasses to get a handle to the internal "singleton"
Expand Down Expand Up @@ -89,7 +64,8 @@ export class O extends HTMLElement {
}
}
disconnectedCallback() {
this.#disconnectedAbortController.abort();
this.disconnectedSignal.
;
}
#internals;
/**
Expand Down
42 changes: 9 additions & 33 deletions froop/O.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ export {OConfig} from '../ts-refs/trans-render/froop/types.js';
import {assignGingerly} from '../lib/assignGingerly.js';
import { RoundAbout } from './roundabout.js';
import { MountObserver } from '../../mount-observer/MountObserver.js';
import {RRMixin} from './RRMixin.js';
const publicPrivateStore = Symbol();

export class O<TProps=any, TActions=TProps> extends HTMLElement implements RoundaboutReady{
export class O<TProps=any, TActions=TProps> extends RRMixin(HTMLElement) implements RoundaboutReady{
propagator = new EventTarget();
[publicPrivateStore]: Partial<TProps> = {};

Expand All @@ -30,46 +31,21 @@ export class O<TProps=any, TActions=TProps> extends HTMLElement implements Round

}

#disconnectedAbortController: AbortController;
// #disconnectedAbortController: AbortController;

get disconnectedSignal(){
return this.#disconnectedAbortController.signal;
}
// get disconnectedSignal(){
// return this.#disconnectedAbortController.signal;
// }

constructor(){
super();
const internals = this.attachInternals();
this.#internals = internals;
this.copyInternals(internals);
this.#disconnectedAbortController = new AbortController();
//this.#disconnectedAbortController = new AbortController();
}

sleep?: number | undefined;
awake() : Promise<void> {
return new Promise((resolve, reject) => {
if(!this.sleep) {
resolve();
return;
}
const ac = new AbortController();
//I'm thinking this one isn't worth wrapping in an EventHandler, as the "closure"
//isn't accessing anything other than the resolve and abort controller, doesn't seem worth it.
this.propagator.addEventListener('sleep', e => {
if(!this.sleep){
ac.abort();
resolve();
}
}, {signal: ac.signal});
})
}
nudge() {
const {sleep} = this;
this.sleep = sleep ? sleep - 1 : 0;
}
rock(){
const {sleep} = this;
this.sleep = sleep=== undefined ? 1 : sleep + 1;
}

/**
* Keep internals reference private, but allow subclasses to get a handle to the internal "singleton"
*/
Expand Down Expand Up @@ -100,7 +76,7 @@ export class O<TProps=any, TActions=TProps> extends HTMLElement implements Round
}

disconnectedCallback(): any {
this.#disconnectedAbortController.abort();
this.disconnectedSignal!.
}

#internals: ElementInternals;
Expand Down
3 changes: 1 addition & 2 deletions froop/RRMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ export const publicPrivateStore = Symbol();
export function RRMixin(Base) {
class RR extends Base {
propagator = new EventTarget();
[publicPrivateStore] = {};
#disconnectedAbortController;
get disconnectedSignal() {
return this.#disconnectedAbortController.signal;
Expand All @@ -19,7 +18,7 @@ export function RRMixin(Base) {
resolve();
return;
}
const ac = new AbortController();
const ac = this.#disconnectedAbortController;
//I'm thinking this one isn't worth wrapping in an EventHandler, as the "closure"
//isn't accessing anything other than the resolve and abort controller, doesn't seem worth it.
this.propagator.addEventListener('sleep', e => {
Expand Down
3 changes: 1 addition & 2 deletions froop/RRMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export const publicPrivateStore = Symbol();
export function RRMixin<T extends Constructor, TProps=any>(Base: T) {
abstract class RR extends Base implements RoundaboutReady {
propagator = new EventTarget();
[publicPrivateStore]: Partial<TProps> = {};

#disconnectedAbortController: AbortController;

Expand All @@ -28,7 +27,7 @@ export function RRMixin<T extends Constructor, TProps=any>(Base: T) {
resolve();
return;
}
const ac = new AbortController();
const ac = this.#disconnectedAbortController;
//I'm thinking this one isn't worth wrapping in an EventHandler, as the "closure"
//isn't accessing anything other than the resolve and abort controller, doesn't seem worth it.
this.propagator.addEventListener('sleep', e => {
Expand Down

0 comments on commit 36a73bc

Please sign in to comment.