Skip to content
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

Feat/options rxdb connection #131

Merged
merged 13 commits into from
May 25, 2023
Merged

Conversation

khalifan-kfan
Copy link
Collaborator

Description

This PR integrates the option tool to an in browser indexed database. It allows a user to update, delete and edit data

Discussion

#106

Preview

Link to app preview if relevant
https://picsa.app/option

Screenshots / Videos

image

Copy link
Collaborator

@chrismclarke chrismclarke left a comment

Choose a reason for hiding this comment

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

Thanks @khalifan-kfan , lots of really useful code here and super nice to see rxdb integrated and working smoothly. In particular I really like how you managed to find a way to initialise the async db creation, and provide strong type defintions to use with the db queries

I've added 2 follow-up commits to help address the challenge of turning this into a feature that can be used across other tools also, specifically

5a50f57
Creates a new shared module that can be used to import the database service into any module. It uses a special forRoot pattern which avoids duplicate initialisation across imports (there will always be just a single global provider, whether using the option-tool standalone, or alongside multiple other tools integrated into the extension app)

The angular docs covers this concept in more detail at:
https://angular.io/guide/singleton-services

196c506
Creates a new option-tool service to refactor some of the code used in the home component,, remove some duplicate type definitions, and change way data is queried.
I've opted to use rxdb's live-query feature, that allows a component to query the database and receive realtime updates when data changes (instead of manually calling a refresh function).

This pattern is pretty common in angular too, although has one minor caveat that any subscriptions need to be unsubscribed when the component is destroyed as can otherwise lead to memory leaks. The article below covers a few ways to do this (you'll see I opted for the rxjs takeUntil utility).
https://blog.bitsrc.io/6-ways-to-unsubscribe-from-observables-in-angular-ab912819a78f

Let me know if you have any questions about the changes, otherwise I think looks good to go!

@github-actions
Copy link

github-actions bot commented May 24, 2023

Visit the preview URL for this PR (updated for commit 46078f9):

https://picsa-extension-toolkit--pr131-feat-options-rxdb-co-fbchidew.web.app

(expires Wed, 31 May 2023 21:50:27 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 2435c4a5f2b9750fe5c819a7a14bcf9433816983

@chrismclarke chrismclarke mentioned this pull request May 25, 2023
8 tasks
@chrismclarke chrismclarke merged commit 853c2a4 into main May 25, 2023
@chrismclarke chrismclarke deleted the feat/options-rxdb-connection branch May 25, 2023 12:08
@khalifan-kfan
Copy link
Collaborator Author

Thanks for the feedback @chrismclarke,
Let me take some time to go through how you achieved that

time: string;
risk: string;
}
import { IOptionsToolEntry } from '../../schemas/schema_v0';
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nice one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants