
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.
Easy state management for React, inspired by Redux and ember-concurrency.
Features:
isLoading
bookkeeping)Design goals:
Define your application state and initialize Tube's task
and connect
utilities:
// src/store.tsx
import initalize from "@chnn/tube"
interface AppState {
count: number
}
const initialState: AppState = { count: 0 }
export const { task, connect } = initialize<AppState>(initialState)
Then connect components to your application state using task
and connect
:
// src/counter.tsx
import * as React from 'react'
import {TaskProp} from '@chnn/tube'
import * as api from "./api"
import { AppState, connect, task } from "./store"
interface Props {
count: number
onIncrement: TaskProp
}
const Counter: React.SFC<Props> = ({ count, onIncrement }) => (
<div className="counter">
<div className="value">
Value: {onIncrement.isRunning ? <div className="loader" /> : count}
</div>
<button onClick={onIncrement}>+ Add 1</button>
</div>
)
const increment = task(function*(getState) {
const x = yield api.getCount(1) // Returns 1 after one second
return { count: getState().count + x }
}).restartable()
const mapStateToProps = (state: AppState) => ({
count: state.count
})
const mapTasksToProps = {
onIncrement: increment
}
export default connect(
mapStateToProps,
mapTasksToProps,
Counter
)
You can run this example yourself.
FAQs
Easy state management for React apps
The npm package @chnn/tube receives a total of 3 weekly downloads. As such, @chnn/tube popularity was classified as not popular.
We found that @chnn/tube demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.