ringsig
ringsig
SSolidJS
Created by ringsig on 10/16/2023 in #support
Dependency on `window`?
Unfortunately this doesn't seem to work as I expected. Some frameworks (like Angular) now complain about importing inexistent symbols (even if they aren't used server-side). The delegateEvents function being generated by the Babel transform plugin seems to be the only cause of the problem (no other dependencies on window). It's also generated rather than imported so even a dynamic import doesn't help (note that I am compiling JSX down to JS because I don't want to expose Solid.js to end-users of the library).
10 replies
SSolidJS
Created by ringsig on 10/16/2023 in #support
Dependency on `window`?
I think the separate entry point would work best here. Thank you!
10 replies
SSolidJS
Created by ringsig on 10/16/2023 in #support
Dependency on `window`?
(It doesn't expose any methods that will be called on the server so there's no need to no-op them, its main purpose is to register a web component)
10 replies
SSolidJS
Created by ringsig on 10/16/2023 in #support
Dependency on `window`?
It shouldn't do anything on the server
10 replies
SSolidJS
Created by ringsig on 10/16/2023 in #support
Dependency on `window`?
Yes, client only, but I don't want it to throw on the server
10 replies
SSolidJS
Created by ringsig on 10/16/2023 in #support
Dependency on `window`?
Unfortunately that seems to generate an actual SSR bundle. What I want to do is to have Solid make the normal browser bundle, but I don't want it to error out on the server. I've investigated the issue a bit further and found that it's because I'm bundling Solid.js into my library. The function delegateEvents in Solid.js depends on window when declared (because of a default parameter). Therefore, the moment my library is imported, if window isn't present, it errors out. I'm still not quite sure how I can solve this. I don't want to have Solid.js as an external library that my consumers need to import.
10 replies
SSolidJS
Created by ringsig on 5/24/2023 in #support
Uncaught TypeError: _tmpl$6 is not a function
I solved this by upgrading the Solid.js version in the host app (it was on an older major version)!
2 replies
SSolidJS
Created by ringsig on 5/21/2023 in #support
Best way to implement a dialog in Solid.js
Alright perfect, exactly what I was looking for. Thanks!
10 replies
SSolidJS
Created by ringsig on 5/21/2023 in #support
Best way to implement a dialog in Solid.js
10 replies
SSolidJS
Created by ringsig on 3/23/2023 in #support
Component doesn't react to changes in Signal
Never mind it appears to be an issue with the third-party library. It somehow breaks reactivity in my entire app
2 replies
SSolidJS
Created by ringsig on 3/15/2023 in #support
Listening to all changes in an array or object in a store
Perfect, thanks!
12 replies
CC#
Created by Ice_ on 3/12/2023 in #help
❔ Entity Framework. Rental list
If you're storing LoanedOn and RepaidOn, you can calculate LoanDuration using RepaidOn and LoanedOn. Traditionally you would use a method to calculate LoanDuration like GetLoanDuration() but C# allows you to use 'getters' which are actually methods but you use them like properties (technically they are properties)
public class Loan
{
public DateTime LoanedOn { get; set; }
public DateTime RepaidOn { get; set; }

public TimeSpan LoanDuration => RepaidOn - LoanedOn;
}
public class Loan
{
public DateTime LoanedOn { get; set; }
public DateTime RepaidOn { get; set; }

public TimeSpan LoanDuration => RepaidOn - LoanedOn;
}
if you have a variable loan, you can access loan.LoanDuration to get the duration. This way you don't have to store LoanDuration separately in a column which would lead to data redundancy (not a good thing—it can lose sync and cause weird bugs)
20 replies
CC#
Created by MattK on 3/5/2023 in #help
❔ Using a loop I need to increment voltage by 0.1.
25 replies
CC#
Created by MattK on 3/5/2023 in #help
❔ Using a loop I need to increment voltage by 0.1.
If you need the voltage in an increment of 0.1 rounding up: ceil(V * 10) / 10
25 replies
CC#
Created by MattK on 3/5/2023 in #help
❔ Using a loop I need to increment voltage by 0.1.
series resistance
= R_1 + R_2
-> R_s

split voltage into ratio R1:R2 and get V_2
V_2 = V * R_2 / (R_1 + R_2)

power from voltage and resistance
P = V^2 / R

write P_2 in terms of resistances and V using expression for V_2
P_2
= V_2^2 / R_2
= (V * R_2 / (R_1 + R_2))^2 / R_2
= (V * R_2)^2 / (R_2 * (R_1 + R_2)^2)
= V^2 * R_2^2 / (R_2 * (R_1 + R_2)^2)
= V^2 * R_2 / (R_1 + R_2)^2

V^2 = P_2 * (R_1 + R_2)^2 / R_2

V = sqrt(P_2 * (R_1 + R_2)^2 / R_2)

P_2 = 1.5

V = sqrt(1.5 * (R_1 + R_2)^2 / R_2)

with specified values:
R_1 = 100
R_2 = 150
R_3 = 150

V
= sqrt(1.5 * (100 + 150)^2 / 150)
= sqrt(1.5 * 250^2 / 150)
= sqrt(1.5 * 62500 / 150)
= sqrt(625)
= 25
series resistance
= R_1 + R_2
-> R_s

split voltage into ratio R1:R2 and get V_2
V_2 = V * R_2 / (R_1 + R_2)

power from voltage and resistance
P = V^2 / R

write P_2 in terms of resistances and V using expression for V_2
P_2
= V_2^2 / R_2
= (V * R_2 / (R_1 + R_2))^2 / R_2
= (V * R_2)^2 / (R_2 * (R_1 + R_2)^2)
= V^2 * R_2^2 / (R_2 * (R_1 + R_2)^2)
= V^2 * R_2 / (R_1 + R_2)^2

V^2 = P_2 * (R_1 + R_2)^2 / R_2

V = sqrt(P_2 * (R_1 + R_2)^2 / R_2)

P_2 = 1.5

V = sqrt(1.5 * (R_1 + R_2)^2 / R_2)

with specified values:
R_1 = 100
R_2 = 150
R_3 = 150

V
= sqrt(1.5 * (100 + 150)^2 / 150)
= sqrt(1.5 * 250^2 / 150)
= sqrt(1.5 * 62500 / 150)
= sqrt(625)
= 25
25 replies
CC#
Created by Ruttie on 12/30/2022 in #help
✅ EntityFrameworkCore lists
No problem 🙂
4 replies
CC#
Created by Ruttie on 12/30/2022 in #help
✅ EntityFrameworkCore lists
Yes, regardless of your database type. This is known as a many-to-one relationship. However, your list items can't be a primitive; they must be a separate entity that lives in the database. For example, you can create a Tag entity which contains the tag's name. In the Tag entity, you may optionally include a reference to the associated Guild and/or its ID. Here's an example model: Guild: - string Id - List<Tag> Tags Tag: - string Id - string Name - Guild Guild (optional) - string GuildId (optional) However, this won't work as string is a primitive type: Guild: - string Id - List<string> Tags That said, it is possible to store direct string lists, but it's not as straightforward. You will have to write a value converter to convert string lists to a type that is supported by EF core and back (like a delimited or JSON string which is not a good idea at all and violates the atomicity principle in ACID). https://learn.microsoft.com/en-us/ef/core/modeling/value-conversions
4 replies