<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Glenn all</title>
    <description>The latest articles on DEV Community by Glenn all (@glenn_all).</description>
    <link>https://dev.to/glenn_all</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F974827%2Fdfb86416-82eb-4740-93d5-0ac480baff5c.jpg</url>
      <title>DEV Community: Glenn all</title>
      <link>https://dev.to/glenn_all</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/glenn_all"/>
    <language>en</language>
    <item>
      <title>Tmux is the Missing Operating System for AI Coding Agents</title>
      <dc:creator>Glenn all</dc:creator>
      <pubDate>Wed, 12 Aug 2026 06:43:11 +0000</pubDate>
      <link>https://dev.to/glenn_all/tmux-is-the-missing-operating-system-for-ai-coding-agents-ej6</link>
      <guid>https://dev.to/glenn_all/tmux-is-the-missing-operating-system-for-ai-coding-agents-ej6</guid>
      <description>&lt;p&gt;You're running two AI agents in parallel on the same codebase. One implements a feature. The other reviews it. A test watcher sits in the corner. Logs stream somewhere. You close your laptop to grab coffee. SSH drops. You open it back up, and half of it is gone.&lt;/p&gt;

&lt;p&gt;This is what happens when you try to scale from "one developer, one command, wait for it to finish" to "multiple agents doing different things at once." Your tools assume serial work. Your actual problem is parallel supervision.&lt;/p&gt;

&lt;p&gt;The article "Tmux Is The Missing Operating System For AI Coding Agents" maps out why this happens and what actually fixes it. The fix isn't a fancy orchestration platform. It's tmux, a terminal multiplexer that's been doing this job well for fifteen years.&lt;/p&gt;

&lt;p&gt;But here's the part that matters: the article doesn't just explain tmux. It shows the specific supervision gaps that emerge when you move from sequential to parallel agent work, and it walks through a concrete workflow that closes those gaps without adding infrastructure you don't need yet.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Fundamental Shift in Your Job
&lt;/h2&gt;

&lt;p&gt;When you ran code yourself, your job was writing every line. When you run AI agents, your job is different: define tasks, allocate context, supervise parallel work, review results, recover processes that failed while you weren't looking.&lt;/p&gt;

&lt;p&gt;That requires a different kind of visibility. Not just "can I see the code" but "can I see what's happening across four simultaneous processes right now, and can I interrupt any of them instantly if something's wrong?"&lt;/p&gt;

&lt;p&gt;Terminal tabs give you visibility. They don't give you persistence or clear boundaries. The moment your SSH connection drops, everything you were watching disappears.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Parallel Work Breaks Terminal Tabs
&lt;/h2&gt;

&lt;p&gt;One developer. One command. Wait for it to finish. Move on. That's the model terminal tabs were built for.&lt;/p&gt;

&lt;p&gt;Parallel agent work breaks it in three specific ways:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Agents work at the same time instead of sequentially.&lt;/strong&gt; An implementation agent, a review agent, a test watcher, a dev server, all alive at once, not one after another.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Processes run long.&lt;/strong&gt; They need to stay visible for as long as they're generating output. Not for two seconds. For hours.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Everything needs continuous visibility.&lt;/strong&gt; Logs, test output, diffs, error traces. Not buried in scrollback you lost twenty minutes ago.&lt;/p&gt;

&lt;p&gt;Terminal tabs organize what you can see right now. They don't organize what keeps running after you look away.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three Concepts, Nothing More
&lt;/h2&gt;

&lt;p&gt;tmux has three concepts:&lt;/p&gt;

&lt;p&gt;A session is a persistent workspace. It keeps running whether you're looking at it or not. Close the terminal window, lose the SSH connection, switch machines entirely. The session stays alive.&lt;/p&gt;

&lt;p&gt;A window is a tab inside that session, usually one project or one task.&lt;/p&gt;

&lt;p&gt;A pane is a single split inside a window, running one process.&lt;/p&gt;

&lt;p&gt;You detach from a session and it keeps going in the background. You reattach later and get the exact terminal state back, scrollback included.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tmux new-session &lt;span class="nt"&gt;-s&lt;/span&gt; ai-workspace
tmux split-window &lt;span class="nt"&gt;-h&lt;/span&gt; &lt;span class="c"&gt;# split vertically&lt;/span&gt;
tmux split-window &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="c"&gt;# split horizontally&lt;/span&gt;
tmux detach &lt;span class="c"&gt;# leave the session running&lt;/span&gt;
tmux attach &lt;span class="nt"&gt;-t&lt;/span&gt; ai-workspace &lt;span class="c"&gt;# come back to exactly where you left off&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;That's most of what you need. The persistence is the actual feature.&lt;/p&gt;
&lt;h2&gt;
  
  
  What Parallel Supervision Actually Requires
&lt;/h2&gt;

&lt;p&gt;You need to see four things at once: what one agent is doing, what another agent thinks about it, whether the tests pass, and what's happening at runtime.&lt;/p&gt;

&lt;p&gt;That's four panes with defined jobs:&lt;/p&gt;

&lt;p&gt;Pane 1: primary agent implementing one scoped change.&lt;br&gt;
Pane 2: independent review agent spotting regressions, not writing code itself.&lt;br&gt;
Pane 3: test watcher running continuously.&lt;br&gt;
Pane 4: server and runtime logs, so you see the effect of changes as they land.&lt;/p&gt;

&lt;p&gt;Your job becomes narrower than either agent's. Approve decisions. Resolve disagreements between what the two agents report. Decide what gets merged. Read the diff yourself before accepting anything.&lt;/p&gt;

&lt;p&gt;Without this separation, more agents just means more noise.&lt;/p&gt;
&lt;h2&gt;
  
  
  The Isolation Problem tmux Doesn't Solve
&lt;/h2&gt;

&lt;p&gt;tmux solves where processes run. It does nothing about two agents editing the same files on the same branch at the same time. That's a bigger source of chaos than any terminal layout.&lt;/p&gt;

&lt;p&gt;The answer is git worktrees:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git worktree add ../project-api &lt;span class="nt"&gt;-b&lt;/span&gt; feature/api
git worktree add ../project-review &lt;span class="nt"&gt;-b&lt;/span&gt; review/api
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;One tmux window per worktree. Each agent has its own filesystem view. Zero risk of stepping on another agent's uncommitted changes.&lt;/p&gt;

&lt;p&gt;tmux isolates processes and views. Git worktrees isolate code. You want both. They solve different problems.&lt;/p&gt;

&lt;p&gt;This matters more than it sounds. The most common failure mode in parallel agent work isn't terminal layout. It's two write-enabled agents in one worktree, creating conflicting edits that take longer to untangle than either agent saved you.&lt;/p&gt;
&lt;h2&gt;
  
  
  Script the Layout, Don't Rebuild It
&lt;/h2&gt;

&lt;p&gt;Rebuilding a six-pane setup by hand every morning gets old around day three.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;
tmux new-session &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;-s&lt;/span&gt; ai-project &lt;span class="nt"&gt;-n&lt;/span&gt; agents
tmux split-window &lt;span class="nt"&gt;-h&lt;/span&gt; &lt;span class="nt"&gt;-t&lt;/span&gt; ai-project:agents
tmux new-window &lt;span class="nt"&gt;-t&lt;/span&gt; ai-project &lt;span class="nt"&gt;-n&lt;/span&gt; tests
tmux new-window &lt;span class="nt"&gt;-t&lt;/span&gt; ai-project &lt;span class="nt"&gt;-n&lt;/span&gt; server
tmux attach &lt;span class="nt"&gt;-t&lt;/span&gt; ai-project
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Save it, commit it next to your project. The layout becomes something you version instead of something you reconstruct from memory.&lt;/p&gt;

&lt;p&gt;A minimal config worth adding on top:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; mouse on
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; history-limit 50000
&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; status-left &lt;span class="s2"&gt;"#[bold]#S "&lt;/span&gt;
&lt;span class="nb"&gt;bind &lt;/span&gt;h &lt;span class="k"&gt;select&lt;/span&gt;&lt;span class="nt"&gt;-pane&lt;/span&gt; &lt;span class="nt"&gt;-L&lt;/span&gt;
&lt;span class="nb"&gt;bind &lt;/span&gt;l &lt;span class="k"&gt;select&lt;/span&gt;&lt;span class="nt"&gt;-pane&lt;/span&gt; &lt;span class="nt"&gt;-R&lt;/span&gt;
&lt;span class="nb"&gt;bind &lt;/span&gt;j &lt;span class="k"&gt;select&lt;/span&gt;&lt;span class="nt"&gt;-pane&lt;/span&gt; &lt;span class="nt"&gt;-D&lt;/span&gt;
&lt;span class="nb"&gt;bind &lt;/span&gt;k &lt;span class="k"&gt;select&lt;/span&gt;&lt;span class="nt"&gt;-pane&lt;/span&gt; &lt;span class="nt"&gt;-U&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The scrollback bump matters. Agent output and error traces from twenty minutes ago disappear fast at the default limit. Re-asking an agent something it already told you wastes both your time and its context window.&lt;/p&gt;
&lt;h2&gt;
  
  
  Persistence: The One Thing That Actually Matters
&lt;/h2&gt;

&lt;p&gt;Closing the terminal window. SSH dropping mid-task. Wi-Fi cutting out. Switching machines. A 40-minute agent run you don't want to babysit.&lt;/p&gt;

&lt;p&gt;Without tmux, any of these kill your work. With it:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tmux detach
tmux list-sessions
tmux attach &lt;span class="nt"&gt;-t&lt;/span&gt; ai-workspace
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The interface disappears. The work doesn't.&lt;/p&gt;

&lt;p&gt;One caveat: this is process-level persistence, not machine-level. Reboot the host and the session goes with it. If work has to survive a full restart, you need something on top, a supervisor process or a restoration script.&lt;/p&gt;
&lt;h2&gt;
  
  
  What tmux Explicitly Doesn't Cover
&lt;/h2&gt;

&lt;p&gt;tmux is a control layer with visibility, interrupt capability, and clear boundaries between concurrent tasks. It has no concept of tasks, dependencies, permissions, or success criteria. It doesn't know what an agent is.&lt;/p&gt;

&lt;p&gt;The judgment about what should run, in what order, who's allowed to touch what, that's still you.&lt;/p&gt;

&lt;p&gt;And critically: an agent with filesystem write access inside a tmux pane has exactly the access it would have outside one. tmux is not a security boundary. Treat it as one and you'll find out the hard way. Pair it with real isolation: tmux plus git worktrees plus containers plus scoped agent permissions. Each layer does the one thing it's actually good at.&lt;/p&gt;
&lt;h2&gt;
  
  
  When to Skip This Approach
&lt;/h2&gt;

&lt;p&gt;A single short-lived agent task doesn't need a persistent multi-pane workspace.&lt;/p&gt;

&lt;p&gt;Work that has to survive a full machine reboot needs something tmux doesn't give you. Multi-user orchestration or agents spread across several machines calls for real infrastructure: CI pipelines, Kubernetes jobs, a dedicated agent-ops tool.&lt;/p&gt;

&lt;p&gt;Anywhere you need actual security or resource isolation, tmux is the wrong layer. That's what containers exist for.&lt;/p&gt;
&lt;h2&gt;
  
  
  Start Here
&lt;/h2&gt;

&lt;p&gt;One session. Four panes. An agent, a server, your tests, your logs. Detach, walk away, come back to a workspace exactly where you left it.&lt;/p&gt;

&lt;p&gt;Plain terminal tabs feel surprisingly fragile after that.&lt;/p&gt;


&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
    &lt;div class="c-embed__content"&gt;
      &lt;div class="c-embed__body flex items-center justify-between"&gt;
        &lt;a href="https://pub.towardsai.net/tmux-is-the-missing-operating-system-for-ai-coding-agents-c173e93781bf" rel="noopener noreferrer" class="c-link fw-bold flex items-center"&gt;
          &lt;span class="mr-2"&gt;pub.towardsai.net&lt;/span&gt;
          

        &lt;/a&gt;
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;



</description>
      <category>ai</category>
      <category>llm</category>
      <category>programming</category>
      <category>opensource</category>
    </item>
    <item>
      <title>how to use react context?</title>
      <dc:creator>Glenn all</dc:creator>
      <pubDate>Sun, 04 Dec 2022 12:01:08 +0000</pubDate>
      <link>https://dev.to/glenn_all/how-to-use-react-context-2fpn</link>
      <guid>https://dev.to/glenn_all/how-to-use-react-context-2fpn</guid>
      <description>&lt;p&gt;React's Context API allows you to share values such as state or data between components without passing props down manually through every level of the component tree. This can be especially useful when you have some values that are needed by many components in your application.&lt;/p&gt;

&lt;p&gt;To use the Context API, you first need to create a context using the createContext() method from the &lt;strong&gt;react&lt;/strong&gt; package. This method returns an object with two components: &lt;strong&gt;Provider&lt;/strong&gt; and &lt;strong&gt;Consumer&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;createContext&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;MyContext&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;createContext&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Provider component is used to provide a value for the context, which can then be consumed by the Consumer component. The Provider component should be placed at the root of your component tree, wrapping the components that need access to the context value.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;MyContext&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./MyContext&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;MyContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Provider&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello World&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;MyComponent&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/MyContext.Provider&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the example above, the value "Hello World" is provided for the MyContext context. This value can then be consumed by the MyComponent component, or any other component nested inside it, using the Consumer component.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;MyContext&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./MyContext&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;MyComponent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;MyContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Consumer&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;}
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/MyContext.Consumer&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;```



The Consumer component expects a function as its child, which will be called with the current context value. The function should return a React element that uses the context value. In the example above, the context value is used to render a p element with the value inside it.

You can also use the useContext() hook from the react package to consume the context value inside a functional component.



```&lt;/span&gt;&lt;span class="nx"&gt;js&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useContext&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;MyContext&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./MyContext&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;MyComponent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;MyContext&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The useContext() hook takes the context object as its argument and returns the current context value. You can then use this value inside the component.&lt;/p&gt;

&lt;p&gt;It's also possible to update the context value using the useState() hook inside a component that is a descendant of the Provider component. This can be useful for implementing state management using the Context API.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useContext&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;MyContext&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./MyContext&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;MyComponent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setValue&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;useContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;MyContext&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;handleClick&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;setValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello World!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;handleClick&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Update&lt;/span&gt; &lt;span class="nx"&gt;Value&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the example above, the context value is initially set to the value provided by the Provider component using the useContext() hook. A button element is then rendered with an onClick event handler that updates the value using the setValue() function from the useState() hook&lt;/p&gt;

</description>
      <category>react</category>
      <category>reactnative</category>
      <category>javascript</category>
      <category>contex</category>
    </item>
    <item>
      <title>what is service discovery? (example provided)</title>
      <dc:creator>Glenn all</dc:creator>
      <pubDate>Sun, 04 Dec 2022 11:13:35 +0000</pubDate>
      <link>https://dev.to/glenn_all/what-is-service-discovery-example-provided-2h81</link>
      <guid>https://dev.to/glenn_all/what-is-service-discovery-example-provided-2h81</guid>
      <description>&lt;p&gt;Service discovery is a process by which services that are available on a network are identified and located. This can be useful in distributed systems, where multiple services may be running on different machines and need to communicate with each other.&lt;/p&gt;

&lt;p&gt;Service discovery typically involves the use of a discovery service, which maintains a list of available services and their locations on the network. Clients can query the discovery service to find the location of a specific service, and then connect to that service directly to access its functionality.&lt;/p&gt;

&lt;h2&gt;
  
  
  Service discovery tools
&lt;/h2&gt;

&lt;p&gt;There are many tools that can be used to implement service discovery in a distributed system. Some common tools include:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Consul&lt;/strong&gt;: Consul is a tool for service discovery and configuration management in distributed systems. It provides a simple and effective way to locate services and manage their configurations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Zookeeper&lt;/strong&gt;: Zookeeper is a distributed coordination service for distributed applications. It provides a centralized registry for services, allowing clients to discover and connect to the services they need.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Eureka&lt;/strong&gt;: Eureka is a service registry for the Netflix OSS ecosystem. It provides a way for services to register themselves and for clients to discover and connect to the services they need.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;etcd&lt;/strong&gt;: etcd is a distributed key-value store that can be used for service discovery. Services can register themselves by storing their metadata in etcd, and clients can discover and connect to the services they need by querying etcd.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Kubernetes&lt;/strong&gt;: Kubernetes is a container orchestration platform that provides built-in support for service discovery. Services can be registered with Kubernetes and accessed using DNS or an API, allowing for easy and efficient discovery and connectivity.&lt;/p&gt;

&lt;p&gt;Here is an example of how service discovery might be implemented using** Express.js** and &lt;strong&gt;Consul&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Register the service with Consul&lt;/span&gt;
&lt;span class="nx"&gt;consul&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;register&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;service-name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8080&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;check&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;http&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;http://localhost:8080/health&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;interval&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;10s&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Create an Express.js app&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;express&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// Register the service with Express.js&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;register&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;service-name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8080&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;check&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;http&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;http://localhost:8080/health&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;interval&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;10s&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Start the Express.js app&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;8080&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="s2"&gt;```

`&lt;/span&gt;

&lt;span class="nx"&gt;In&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt; &lt;span class="nx"&gt;example&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;the&lt;/span&gt; &lt;span class="nx"&gt;service&lt;/span&gt; &lt;span class="nx"&gt;is&lt;/span&gt; &lt;span class="nx"&gt;registered&lt;/span&gt; &lt;span class="kd"&gt;with&lt;/span&gt; &lt;span class="nx"&gt;both&lt;/span&gt; &lt;span class="nx"&gt;Consul&lt;/span&gt; &lt;span class="nx"&gt;and&lt;/span&gt; &lt;span class="nx"&gt;Express&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;js&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;providing&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;way&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nx"&gt;clients&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt; &lt;span class="nx"&gt;discover&lt;/span&gt; &lt;span class="nx"&gt;and&lt;/span&gt; &lt;span class="nx"&gt;connect&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt; &lt;span class="nx"&gt;the&lt;/span&gt; &lt;span class="nx"&gt;service&lt;/span&gt; &lt;span class="nx"&gt;using&lt;/span&gt; &lt;span class="nx"&gt;either&lt;/span&gt; &lt;span class="nx"&gt;tool&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt; &lt;span class="nx"&gt;Consul&lt;/span&gt; &lt;span class="nx"&gt;is&lt;/span&gt; &lt;span class="nx"&gt;also&lt;/span&gt; &lt;span class="nx"&gt;used&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt; &lt;span class="nx"&gt;manage&lt;/span&gt; &lt;span class="nx"&gt;the&lt;/span&gt; &lt;span class="nx"&gt;service&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;s configuration, allowing for dynamic updates without requiring a restart.



&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>frontend</category>
      <category>webdev</category>
      <category>discuss</category>
    </item>
    <item>
      <title>what is microservice architecture?</title>
      <dc:creator>Glenn all</dc:creator>
      <pubDate>Sun, 04 Dec 2022 10:10:11 +0000</pubDate>
      <link>https://dev.to/glenn_all/what-is-micro-service-architecture-12j9</link>
      <guid>https://dev.to/glenn_all/what-is-micro-service-architecture-12j9</guid>
      <description>&lt;p&gt;Microservice architecture is a design approach for building software systems that are composed of small, independent, and modular components, known as microservices. &lt;/p&gt;

&lt;p&gt;Each microservice is designed to perform a specific function or set of related functions, and can be developed, deployed, and maintained independently of the other microservices in the system. This allows for flexibility, scalability, and resiliency, as the system can be easily adapted and evolved to meet changing requirements.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example of microservice:
&lt;/h2&gt;

&lt;p&gt;let's define a simple &lt;strong&gt;microservice&lt;/strong&gt; that exposes a single endpoint &lt;strong&gt;/add&lt;/strong&gt; which accepts two numbers as query parameters, a and b, and returns the result of adding them.&lt;/p&gt;

&lt;p&gt;tech stack Express&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// A simple function that adds two numbers&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Define an endpoint that accepts two numbers&lt;/span&gt;
&lt;span class="c1"&gt;// and returns the result of adding them&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/add&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;parseInt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;parseInt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;send&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Start the server on port 3000&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Microservice listening on port 3000!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To run this microservice, you would need to install the required dependencies, such as Express, and then start the server by running the code. Once the server is running, you can send HTTP requests to the /add endpoint to test it out. For example, you could use the following curl command to send a request to add 2 and 3:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;curl 'http://localhost:3000/add?a=2&amp;amp;b=3'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This would return the following response:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;{"result":5}&lt;/code&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
