Code Monkey home page Code Monkey logo

react-hooks's Introduction

NodeCG

NodeCG

Discord Build Status Coverage Status Docker Build Status Twitter

NodeCG is a broadcast graphics framework and application. It enables you to write complex, dynamic broadcast graphics using the web platform. NodeCG has no graphics or drawing primitives of its own. Instead, NodeCG provides a structure for your code and an API to facilitate moving data between the dashboard, the server, and your graphics. It makes few assumptions about how to best code a graphic, and gives you freedom to use whatever libraries, frameworks, tools, and methodologies you want. As such, NodeCG graphics can be rendered in any environment that can render HTML, including:

Don't see your preferred streaming software on this list? NodeCG graphics require a modern browser engine. If your streaming software's implementation of browser source uses a recent-ish browser engine, chances are that NodeCG graphics will work in it. You can check what version your streaming software uses for its browser sources by opening whatversion.net/chrome as a browser source.

Have questions about NodeCG, or just want to say 'hi'? Join our Discord server!

Documentation & API Reference

Full docs and API reference are available at https://nodecg.dev

Goals

The NodeCG project exists to accomplish the following goals:

  • Make broadcast graphics (also known as "character generation" or "CG") more accessible.
  • Remain as close to the web platform as possible.
  • Support broadcasts of any size and ambition.

Let's unpack what these statements mean:

> Make broadcast graphics (also known as "character generation" or "CG") more accessible

Historically, broadcast graphics have been expensive. They either required expensive hardware, expensive software, or both. NodeCG was originally created to provide real-time broadcast graphics for Tip of the Hats, which is an all-volunteer charity fundraiser that had a budget of $0 for its first several years.

Now, it is possible to create an ambitious broadcast using entirely free software and consumer hardware. The NodeCG project embraces this democratization of broadcast technology.

> Remain as close to the web platform as possible

NodeCG graphics are just webpages. There is absolutely nothing special or unique about them. This is their greatest strength.

By building on the web platform, and not building too many abstractions on top of it, people developing broadcast graphics with NodeCG have access to the raw potential of the web. New APIs and capabilities are continually being added to the web platform, and NodeCG developers should have access to the entirety of what the web can offer.

> Support broadcasts of any size and ambition

NodeCG's roots are in small broadcasts with no budget. More recently, NodeCG has begun seeing use in increasingly elaborate productions. We believe that one set of tools can and should be able to scale up from the smallest show all the way to the biggest fathomable show. Whether you're using OBS for everything, or a hardware switcher with a traditional key/fill workflow, NodeCG can be a part of any broadcast graphics system.

Maintainers

Designers

Acknowledgements

react-hooks's People

Contributors

abrahamic-god avatar carlosfdez avatar ewanlyon avatar github-actions[bot] avatar hoishin avatar renovate[bot] avatar tedkulp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

react-hooks's Issues

New hook: pass replicant directly to hooks

const counterRep = nodecg.Replicant<number>('counter');

const Counter: React.FunctionComponent = () => {
	const [count, updateCount] = useNewHookName(counterRep, null);

	// ...
};

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Pending Approval

These branches will be created by Renovate only once you click their checkbox below.

  • chore(deps): update dependency @types/lodash.clone to v4.5.7
  • chore(deps): update dependency del-cli to v3.0.1
  • chore(deps): update dependency husky to v4.3.8
  • chore(deps): update dependency lint-staged to v10.5.4
  • chore(deps): update dependency ts-jest to v28.0.8
  • chore(deps): update dependency typescript to v4.9.5
  • chore(deps): update react monorepo to v18.0.28 (@types/react, @types/react-dom)
  • chore(deps): update dependency @hoishin/prettierrc to v2.2.0
  • chore(deps): update dependency @hoishin/tsconfig to v2.1.0
  • chore(deps): update dependency @types/node to v12.20.55
  • chore(deps): update dependency eslint-config-hoishin to v0.4.2
  • chore(deps): update dependency prettier to v2.8.7
  • chore(deps): update dependency sort-package-json to v1.57.0
  • fix(deps): update dependency tslib to v2.5.0
  • chore(deps): update actions/checkout action to v3
  • chore(deps): update actions/setup-node action to v3
  • chore(deps): update dependency @testing-library/react to v14
  • chore(deps): update dependency @types/node to v18
  • chore(deps): update dependency del-cli to v5
  • chore(deps): update dependency eslint to v8
  • chore(deps): update dependency husky to v8
  • chore(deps): update dependency lint-staged to v13
  • chore(deps): update dependency nodecg to v2
  • chore(deps): update dependency sort-package-json to v2
  • chore(deps): update dependency standard-version to v9
  • chore(deps): update dependency typescript to v5
  • chore(deps): update jest monorepo to v29 (major) (@types/jest, jest, ts-jest)
  • ๐Ÿ” Create all pending approval PRs at once ๐Ÿ”

Detected dependencies

github-actions
.github/workflows/ci.yml
  • actions/checkout v2
  • actions/setup-node v1
npm
package.json
  • lodash.clone ^4.5.0
  • tslib ^2.0.0
  • @hoishin/prettierrc 2.1.1
  • @hoishin/tsconfig 2.0.0
  • @testing-library/react ^13.4.0
  • @types/jest 28
  • @types/lodash.clone 4.5.6
  • @types/node 12.12.29
  • @types/react ^18.0.0
  • @types/react-dom ^18.0.0
  • del-cli 3.0.0
  • eslint 6.8.0
  • eslint-config-hoishin 0.3.0
  • husky 4.3.0
  • jest 28.1.3
  • jest-environment-jsdom ^29.5.0
  • lint-staged 10.5.1
  • nodecg 1.9.0
  • npm-run-all 4.1.5
  • prettier 2.0.0
  • react ^18.0.0
  • react-dom ^18.0.0
  • sort-package-json 1.46.1
  • standard-version ^8.0.0
  • ts-jest 28.0.1
  • typescript ^4.5.4

  • Check this box to trigger a request for Renovate to run again on this repository

Enhance hooks related to NodeCG messages

There is useListenFor hook but it's really a basic hook that only registers a callback to nodecg.listenFor.

It would be nice to receive feedback and use cases so it can be more useful.

useReplicant default value unable to set, causing updated project to fail to load.

Giving a simple example of what I'm trying to do:

function Timing() {
  const [count, setCount] = useReplicant("counter");
  return (
    <div>
      <div>{count.length}</div>
      <button onClick={() => setCount([count[0] + 1])} />
    </div>
  );
}

setCount returns an array containing a cell containing the number 1.

I'm getting Cannot read properties of undefined (reading 'length') I understand where this is coming from.

I've tried setting setCount([]) directly after the const = ... before the return (...)

I tried what previously worked const [count, setCount] = useReplicant("counter", []);
I'm not sure what the correct way to set this up is, it worked previously before doing a dependency and node update.

Totally understand this is in ALPHA and asking questions is probably not helpful, but as a point of feedback, If I can't set a default value or object it's a bit useless.

I read through the src of useReplicant and couldn't workout the new way to pass in a default value/object to the Rep.

Node20 - LTS
react - 18
nodecg - latest
@nodecg-react-hooks - latest

happy to list any thing else needed but I believe these are the minimum required to cause an error.

Consider migrating to NodeCG org

I think this library has been around long enough and used enough that it could be made into v1.0 and live on the NodeCG org instead of here. Up to you, though!

Rename package

useSomething is a conventional name for hooks, but it's not ideal for npm package names because of vagueness. There are number of options but I'm leaning to @nodecg/react-hooks

useReplicant doesn't support namespaces

nodecg.Replicant has a 2nd optional parameter for namespace. Unfortunately, the bundle I'm working with uses it exclusively. See: https://nodecg.com/NodeCG.html#Replicant

I did make a quick version of useReplicantNS as a workaround, but would rather get something into your main repository. I didn't know if maybe adding it to the options and taking it out if it exists is better for your API than making a whole new method.

I'm willing to make and submit the change, but I didn't want to do extra work that you might want to do differently anyway.

Thanks. Great work so far!

useReplicant doesn't support passing a function to setReplicant

An example with useState and useReplicant:

const [data, setData] = React.useState(0);
setData(previousData => previousData + 1);

const [replicant, setReplicant] = useReplicant(0);
setReplicant(previousData => previousData + 1); // this is not supported!

Would be great if that was supported, because old values could be captured when using useEffect for example.

useReplicant contains stale values when using a different repName/namespace.

Currently, swapping out the namespace using a prop does not cause useReplicant to use the new replicant name. My suspicion is that its because the internal useEffect never runs on subsequent re-renders.

Here's a gist where this problem manifests. The "OBSControlView" object always binds to the first namespace, even if the prop changes.

https://gist.github.com/CarlosFdez/ab3ab575a62c048daacb8f6b38a6f2d3

My suggestion is to add repName as a param to line 39. I wanted to ask here for the go-ahead before doing it.

Implement unit tests for hooks

It currently has no unit test since I couldn't find a good way to write one when I initially made this library, but it really needs tests.

I have skeleton tests unfinished that can be a starting point.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.