-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
47ea02f
commit c8e1e8a
Showing
14 changed files
with
355 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from typing import Callable, TypeVar | ||
|
||
from arclet.letoderea import Subscriber | ||
from arclet.letoderea.typing import TTarget | ||
|
||
T = TypeVar("T") | ||
|
||
|
||
class SubscribeLoader: | ||
sub: Subscriber | ||
|
||
def __init__(self, func: TTarget[T], caller: Callable[[TTarget[T]], Subscriber[T]]): | ||
self.func = func | ||
self.caller = caller | ||
self.loaded = False | ||
|
||
def load(self): | ||
if not self.loaded: | ||
self.sub = self.caller(self.func) | ||
self.loaded = True | ||
return self.sub | ||
|
||
def dispose(self): | ||
if self.loaded: | ||
self.sub.dispose() | ||
self.loaded = False | ||
del self.func | ||
del self.caller |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.