Skip to main content

Posts

Featured

Using PubSubJS in React

Here I demonstrate how to use PubSubJS to allow a React component to listen for changes to some external object (external to the React application). The problem being solved: I want an array of strings to exist globally such that any Javascript code can modify it (primarily to add to it), while at the same time providing a method for a visual component to listen to state changes on that array and update an on-screen list of those strings. Main use case I had in mind: helping me to write React code via codepen.io when on my iPad and have no access to Developer Tools, which means I can't see console.log messages. Helpful resouce: Communication Between Independent Components in React using PubSubJS PubSubJS API lives at: https://www.npmjs.com/package/pubsub-js . See my live example of this at codepen.io . The HTML is extremely basic, just providing a root object for React to hook into. <div id="root"></div> The Javascript contains all the re

Latest Posts

Two ways to find files and grep through them in bash

Five for loops in Java

De-serialise JSON string to map with multiple value types

Data driven tests in JUnit 5 with exception handling

Debug TestNG data driven tests when you only want to debug one row of data

Bash script to repeat a task until you tell it to stop

Scripts and .screenrc to make GNU Screen splits easier

Maven project with Spring, Log4j2 and properties

Date time stamps in bash with ordinal indicator

JQuery UI tooltip with a close link for mobile