Skip to content

chore: cleanup code #189

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

Merged
merged 11 commits into from
Jan 24, 2023
Merged

chore: cleanup code #189

merged 11 commits into from
Jan 24, 2023

Conversation

dummdidumm
Copy link
Member

@dummdidumm dummdidumm commented Jan 23, 2023

closes #139

  • move adapter stuff into its own component Output.svelte
  • move icons into one folder
  • move filetree into route where it's used and integrate more obviously with state
  • make it more robust to rapid editing / resolve / switch actions through queue-like implementation in adapter.js
  • make state easier to reason about by moving it into state.js with proper functions instead of writing to different writables all other the place

@vercel
Copy link

vercel bot commented Jan 23, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
learn-svelte-dev ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Jan 24, 2023 at 5:45PM (UTC)

@dummdidumm dummdidumm marked this pull request as ready for review January 23, 2023 21:19

/** @type {'idle' | 'renaming'} */
let state = 'idle';
let editing_state = 'idle';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we just make this a boolean?

@Rich-Harris Rich-Harris mentioned this pull request Jan 23, 2023
Comment on lines 39 to 62
if (state.status === 'set' || state.status === 'switch') {
loading = true;

try {
clearTimeout(timeout);
await reset_adapter(state.stubs);

if (state.status === 'switch') {
set_iframe_src(adapter.base + path);
}

initial = false;
} catch (e) {
error = /** @type {Error} */ (e);
console.error(e);
}

loading = false;
} else if (state.status === 'update' && state.last_updated) {
const reload = await adapter.update([state.last_updated]);
if (reload) {
schedule_iframe_reload();
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this stuff feels racy — i feel like this logic belongs elsewhere, though i don't have a great design to offer right now

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The race conditions should be handled internally in adapter.js, though I now realize I'm not making use of the "cancelled" outcome here

@Rich-Harris Rich-Harris merged commit 46dda23 into main Jan 24, 2023
@Rich-Harris Rich-Harris deleted the cleanup branch January 24, 2023 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

make the code better
2 participants