Skip to content

Commit

Permalink
Fixed a bug in the selective context where the update was recalculate…
Browse files Browse the repository at this point in the history
…d for every listener, instead of propagating the new master value.
  • Loading branch information
buchananwill committed Apr 9, 2024
1 parent af1b557 commit 0d16358
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion app/playground/arcChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default function ArcChart({ data }: { data: number[][] }) {
BASE_HSL[HUE_OPTIONS[chord.target.index % HUE_OPTIONS.length].id]
.cssHSLA;
const endColor =
BASE_HSL[HUE_OPTIONS[chord.source.index % HUE_OPTIONS.length].id]
BASE_HSL[HUE_OPTIONS[chord.target.index % HUE_OPTIONS.length].id]
.cssHSLA;
return (
<linearGradient id={id} x1="0%" y1="0%" x2="100%" y2="0%" key={id}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function useSelectiveContextManager<T>(
if (currentElement !== newValue) {
try {
Object.values(listeners).forEach((l) => {
l(update);
l(newValue);
});
} catch (e) {
console.error(e);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use client';
import { createSelectiveContext } from '../base/generic-selective-context-creator';

export const SelectContextGlobal = createSelectiveContext<any>();
export const SelectiveContextGlobal = createSelectiveContext<any>();
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';
import { PropsWithChildren } from 'react';
import GenericSelectiveContextManager from '../base/generic-selective-context-manager';
import { SelectContextGlobal } from './selective-context-creator-global';
import { SelectiveContextGlobal } from './selective-context-creator-global';
import {
useSelectiveContextController,
UseSelectiveContextParams
Expand All @@ -13,7 +13,7 @@ export default function SelectiveContextManagerGlobal({
children
}: PropsWithChildren) {
return (
<GenericSelectiveContextManager {...SelectContextGlobal}>
<GenericSelectiveContextManager {...SelectiveContextGlobal}>
{children}
</GenericSelectiveContextManager>
);
Expand All @@ -28,9 +28,9 @@ export function useSelectiveContextAnyController<T>({
contextKey,
listenerKey,
initialValue,
SelectContextGlobal.listenerRefContext,
SelectContextGlobal.latestValueRefContext,
SelectContextGlobal.dispatchContext
SelectiveContextGlobal.listenerRefContext,
SelectiveContextGlobal.latestValueRefContext,
SelectiveContextGlobal.dispatchContext
);
}
export function useSelectiveContextAnyDispatch<T>({
Expand All @@ -42,9 +42,9 @@ export function useSelectiveContextAnyDispatch<T>({
contextKey,
listenerKey,
initialValue,
SelectContextGlobal.listenerRefContext,
SelectContextGlobal.latestValueRefContext,
SelectContextGlobal.dispatchContext
SelectiveContextGlobal.listenerRefContext,
SelectiveContextGlobal.latestValueRefContext,
SelectiveContextGlobal.dispatchContext
);
}

Expand All @@ -57,7 +57,7 @@ export function useSelectiveContextGlobalListener<T>({
contextKey,
listenerKey,
initialValue,
SelectContextGlobal.listenerRefContext,
SelectContextGlobal.latestValueRefContext
SelectiveContextGlobal.listenerRefContext,
SelectiveContextGlobal.latestValueRefContext
);
}

0 comments on commit 0d16358

Please sign in to comment.