Skip to content

Commit

Permalink
$mol_service refactor detach method, auto init
Browse files Browse the repository at this point in the history
  • Loading branch information
zerkalica committed Oct 30, 2024
1 parent 354468b commit 7a0cf1e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion offline/install/install.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
namespace $ {
$mol_service.attach($mol_offline)
// Not needed, just refer to $mol_offline anywhere
// $mol_service.attach($mol_offline)
}
1 change: 1 addition & 0 deletions offline/offline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,5 @@ namespace $ {
}
}

$mol_service.attach($mol_offline)
}
8 changes: 6 additions & 2 deletions service/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ namespace $ {

static attach(plugin: typeof $mol_service_plugin) {
this.plugins.add(plugin)
this.init()
}

protected static init() {}
static detach(plugin: typeof $mol_service_plugin) {
this.plugins.delete(plugin)
}

static init() {}

static blocked_response() {
return new Response(
Expand All @@ -27,4 +30,5 @@ namespace $ {
)
}
}

}
4 changes: 3 additions & 1 deletion service/service.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace $ {

protected static inited = false

protected static override init() {
static override init() {
if (this.inited) return

if ( this.in_worker() ) {
Expand Down Expand Up @@ -171,4 +171,6 @@ namespace $ {

$.$mol_service = $mol_service_web

$mol_service_web.init()

}

0 comments on commit 7a0cf1e

Please sign in to comment.