McBrincie212
McBrincie212
SSolidJS
Created by McBrincie212 on 2/23/2025 in #support
Having The Same Context Transfer Different Properties
i've tried that, tbh it feels wrong to me on many levels]
53 replies
SSolidJS
Created by McBrincie212 on 2/23/2025 in #support
Having The Same Context Transfer Different Properties
like have a sort of type property that has the discriminated union of canvas and base-widget?
53 replies
SSolidJS
Created by McBrincie212 on 2/23/2025 in #support
Having The Same Context Transfer Different Properties
i might have to embrace this
53 replies
SSolidJS
Created by McBrincie212 on 2/23/2025 in #support
Having The Same Context Transfer Different Properties
and as u said its better to have the contexts seperate
53 replies
SSolidJS
Created by McBrincie212 on 2/23/2025 in #support
Having The Same Context Transfer Different Properties
i don't think tbh it would work out
53 replies
SSolidJS
Created by McBrincie212 on 2/23/2025 in #support
Having The Same Context Transfer Different Properties
export interface BaseWidgetPropertiesInterface<T> extends RenderableComponentProperties {
// <...>
subProperties: T
}
export interface BaseWidgetPropertiesInterface<T> extends RenderableComponentProperties {
// <...>
subProperties: T
}
53 replies
SSolidJS
Created by McBrincie212 on 2/23/2025 in #support
Having The Same Context Transfer Different Properties
turn it maybe to something like this
53 replies
SSolidJS
Created by McBrincie212 on 2/23/2025 in #support
Having The Same Context Transfer Different Properties
where it would also be a object
53 replies
SSolidJS
Created by McBrincie212 on 2/23/2025 in #support
Having The Same Context Transfer Different Properties
i had like subProperties field
53 replies
SSolidJS
Created by McBrincie212 on 2/23/2025 in #support
Having The Same Context Transfer Different Properties
export interface BaseWidgetPropertiesInterface extends RenderableComponentProperties {
getWidth: () => number,
getHeight: () => number,
getOffset: () => [number, number],
isWidgetPicked: () => boolean,
setIsWidgetPicked: (val: boolean) => void,
setOffset: (val: [number, number]) => void,
setHeight: (val: number) => void,
setWidth: (val: number) => void,
getTitle: () => string,
setTitle: (val: string) => void,
getIsActive: () => boolean,
setIsActive: (val: boolean) => void,
getContent: () => () => JSXElement,
setContent: (value: () => JSXElement) => void,
isSelectable: boolean
}
export interface BaseWidgetPropertiesInterface extends RenderableComponentProperties {
getWidth: () => number,
getHeight: () => number,
getOffset: () => [number, number],
isWidgetPicked: () => boolean,
setIsWidgetPicked: (val: boolean) => void,
setOffset: (val: [number, number]) => void,
setHeight: (val: number) => void,
setWidth: (val: number) => void,
getTitle: () => string,
setTitle: (val: string) => void,
getIsActive: () => boolean,
setIsActive: (val: boolean) => void,
getContent: () => () => JSXElement,
setContent: (value: () => JSXElement) => void,
isSelectable: boolean
}
what if on this
53 replies
SSolidJS
Created by McBrincie212 on 2/23/2025 in #support
Having The Same Context Transfer Different Properties
wait a minute
53 replies
SSolidJS
Created by McBrincie212 on 2/23/2025 in #support
Having The Same Context Transfer Different Properties
lets reinvent the wheel
53 replies
SSolidJS
Created by McBrincie212 on 2/23/2025 in #support
Having The Same Context Transfer Different Properties
to not have to write the same thing basically over and over again
53 replies
SSolidJS
Created by McBrincie212 on 2/23/2025 in #support
Having The Same Context Transfer Different Properties
for the above tho, is it reccomended if i do something like have createContextBoilerplate<T>
53 replies
SSolidJS
Created by McBrincie212 on 2/23/2025 in #support
Having The Same Context Transfer Different Properties
i mean i got it, its inevitable
53 replies
SSolidJS
Created by McBrincie212 on 2/23/2025 in #support
Having The Same Context Transfer Different Properties
mhm
53 replies
SSolidJS
Created by McBrincie212 on 2/23/2025 in #support
Having The Same Context Transfer Different Properties
since this pattern is used commonly
53 replies
SSolidJS
Created by McBrincie212 on 2/23/2025 in #support
Having The Same Context Transfer Different Properties
tbh im thinking of making this a factory method
import {Context, createContext, JSXElement, useContext} from "solid-js";
import {BaseWidgetPropertiesInterface} from "./BaseWidgetCreator.tsx";

export const BaseWidgetContext: Context<BaseWidgetPropertiesInterface | undefined> = createContext();

export function useBaseWidgetContext(): BaseWidgetPropertiesInterface {
const context: BaseWidgetPropertiesInterface | undefined = useContext(BaseWidgetContext);
if (!context) throw new Error("useBaseWidgetContext must be used within a BaseWidgetProvider");
return context;
}

export function BaseWidgetProvider(props: { properties: BaseWidgetPropertiesInterface; children: JSXElement }) {
return (
<BaseWidgetContext.Provider value={props.properties}>
{props.children}
</BaseWidgetContext.Provider>
);
}
import {Context, createContext, JSXElement, useContext} from "solid-js";
import {BaseWidgetPropertiesInterface} from "./BaseWidgetCreator.tsx";

export const BaseWidgetContext: Context<BaseWidgetPropertiesInterface | undefined> = createContext();

export function useBaseWidgetContext(): BaseWidgetPropertiesInterface {
const context: BaseWidgetPropertiesInterface | undefined = useContext(BaseWidgetContext);
if (!context) throw new Error("useBaseWidgetContext must be used within a BaseWidgetProvider");
return context;
}

export function BaseWidgetProvider(props: { properties: BaseWidgetPropertiesInterface; children: JSXElement }) {
return (
<BaseWidgetContext.Provider value={props.properties}>
{props.children}
</BaseWidgetContext.Provider>
);
}
53 replies
SSolidJS
Created by McBrincie212 on 2/23/2025 in #support
Having The Same Context Transfer Different Properties
ok
53 replies
SSolidJS
Created by McBrincie212 on 2/23/2025 in #support
Having The Same Context Transfer Different Properties
so i can't escape 2 contexts at once
53 replies