![Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility](https://cdn.sanity.io/images/cgdhsj6q/production/97774ea8c88cc8f4bed2766c31994ebc38116948-1664x1366.png?w=400&fit=max&auto=format)
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
ncore-context
Advanced tools
Global State Management Library for NCore
yarn add ncore-context
const ExampleTheme = new NCoreContext({
spaces: {
container: 20,
content: 10
},
colors: {
primary: "#00c2a9",
success: "green",
accent: "red"
}
}, {
isSaveState: true,
key: "key1"
});
const ContextAPI = () => {
useEffect(() => {
theme.addEventListener("a", themeChanged);
theme.addEventListener("b", themeChanged2);
}, []);
const themeChanged = (newState: any) => {
console.error("STATE CHANGED. NEW STATE:", newState);
};
const themeChanged2 = (newState: any) => {
console.error("STATE CHANGED 2. NEW STATE 2:", newState);
};
const {
colors
} = theme.useContext();
return <View
style={{
backgroundColor: "#242424",
flex: 1
}}
>
<Text
style={{
color: colors.success,
fontSize: 60
}}
>
Test Text
</Text>
<Button
title="SET PALETTE"
onPress={() => {
theme.setState({
colors: {
success: "pink",
accent: "blue",
primary: "#00c2a9"
}
});
}}
/>
<Button
title="SET PALETTE WITH 2"
onPress={() => {
theme.setState({
colors: {
primary: "#00c2a9",
success: "green",
accent: "red"
}
});
}}
/>
<Button
title="REMOVE A LISTENER"
onPress={() => {
theme.removeEventListener("a");
}}
/>
</View>;
};
const App = () => {
return <theme.Provider>
<ContextAPI/>
</theme.Provider>;
};
export default App;
class ThemeContextInheritance<T extends {} | undefined> extends NCoreContext<T> {
themes = [light, dark];
constructor(initialState: any, config: ConfigType<T>) {
super(initialState, config);
this.prepare(initialState);
}
setTheme = (themeKey: NCore.ThemeKeyType) => {
const currentProjectTheme = this.themes?.find(e => e.key === themeKey);
if(themeKey !== "light" && themeKey !== "dark" && !(currentProjectTheme)) {
throw Error(`Can not find a theme for the given themeKey: ${themeKey}`);
}
const _typography = mergeGivenTypographyWithNCore(themeKey, currentProjectTheme?.typography);
const _colors = mergeGivenColorsWithNCore(themeKey, currentProjectTheme?.colors);
const _designTokens = mergeGivenDesignTokensWithNCore(themeKey, currentProjectTheme?.designTokens);
this.setState({
activeTheme: themeKey,
typography: _typography,
colors: _colors,
spaces: _designTokens.spaces,
borders: _designTokens.borders,
radiuses: _designTokens.radiuses,
disabled: _designTokens.disabled
});
};
prepare = (initialState: any) => {
if(!initialState) {
return;
}
if(initialState.themes) {
this.themes = initialState.themes;
}
if(initialState.initialThemeKey) {
this.setTheme(initialState.initialThemeKey);
}
};
};
const ThemeContext = new ThemeContextInheritance(
themeStore,
{
key: "NCoreTheme"
}
);
MIT + NİBGAT® | License - OSL
FAQs
NİBGAT® | NCore - Context
The npm package ncore-context receives a total of 66 weekly downloads. As such, ncore-context popularity was classified as not popular.
We found that ncore-context demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.