-
-
Notifications
You must be signed in to change notification settings - Fork 552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Image loading queuing #11
Conversation
@@ -0,0 +1,24 @@ | |||
export class ImageLoader { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
może ImageLoadManager? ImageLoadQueueManager?
fajnie by było zrobić klasę bazową która pomagałaby implementować kolejkowanie. ale nie rób teraz.
zrobisz jak będziesz miał odpicowaną tą klasę
@@ -0,0 +1,24 @@ | |||
export class ImageLoader { | |||
|
|||
private static queue = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
otypuj że zbierasz tutaj funkcje. koniecznie asynchroniczne
private static queue = []; | ||
private static isRunning: boolean = false; | ||
|
||
public static add(fx: any) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
też otypuj. wiem że się przypierdzielam ale tak będzie wygodniej później
private static async runTasks() { | ||
while (ImageLoader.queue.length > 0) { | ||
const fx = ImageLoader.queue.shift(); | ||
await fx(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ten await działa (tak jak tego oczekujesz) w pętli while? nie wiem xD pytam?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tak, testowałem i śmiga. Dałem wfile, bo jest lepszy od fora, bo mogę w między czasie ushować i shiftować z array i nie musze się martwić tym że form a z góry stałą ilość elementów.
this.resizeCanvas(size); | ||
this.primaryRenderingEngine = new PrimaryEditorRenderEngine(this.canvas, this.imageRectOnCanvas); | ||
this.mountSupportRenderingEngine(activeLabelType); | ||
this.fullCanvasRender() | ||
this.fullCanvasRender(); | ||
setTimeout(() => ImageLoader.run(), 10); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no właśnie... dlatego napisałem że to bieda kolejkowanie bo tak zasugerowałem żeby zrobić :/
na tę chwilę to rozwiązanie może być. ale wypadałoby wymyślić jakieś lepsze
@@ -76,14 +82,17 @@ class Editor extends React.Component<IProps, IState> { | |||
|
|||
public componentDidUpdate(prevProps: Readonly<IProps>, prevState: Readonly<IState>, snapshot?: any): void { | |||
if (prevProps.imageData.id !== this.props.imageData.id) { | |||
this.loadImage(this.props.imageData); | |||
ImageLoader.add(async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ten kawałek kodu się powtarza więc zapisz do metody w tej klasie/utilu
ImageLoader.add(async () => { | ||
await this.loadImage(this.props.imageData, this.props.isScrolling); | ||
}); | ||
setTimeout(() => ImageLoader.run(), 10); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tutaj tez są powtarzające się kawałki kodu
No description provided.