Knowledge Updates

Observations while developing web applications and creating great software.

  • Apple will spend more than $500 billion in the U.S. over the next four years ↗

    Apple:

    Apple today announced its largest-ever spend commitment, with plans to spend and invest more than $500 billion in the U.S. over the next four years. This new pledge builds on Apple’s long history of investing in American innovation and advanced high-skilled manufacturing, and will support a wide range of initiatives that focus on artificial intelligence, silicon engineering, and skills development for students and workers across the country.

    “We are bullish on the future of American innovation, and we’re proud to build on our long-standing U.S. investments with this $500 billion commitment to our country’s future,” said Tim Cook, Apple’s CEO. “From doubling our Advanced Manufacturing Fund, to building advanced technology in Texas, we’re thrilled to expand our support for American manufacturing. And we’ll keep working with people and companies across this country to help write an extraordinary new chapter in the history of American innovation.”

  • Music to Refine To ↗

    Apple x ODESZA:

    An exclusive ODESZA set designed for eight hours of focus—perfect for your innie’s workday.

    Season 2 of Severance is out now.

    In Severance, Mark Scout (Adam Scott) leads a team at Lumon Industries, whose employees have undergone a severance procedure, which surgically divides their memories between their work and personal lives. This daring experiment in “work-life balance” is called into question as Mark finds himself at the center of an unraveling mystery that will force him to confront the true nature of his work… and of himself.

  • Migrating Apple Account purchases between accounts ↗

    Apple:

    You can choose to migrate apps, music, and other content you’ve purchased from Apple on a secondary Apple Account to a primary Apple Account. The secondary Apple Account might be an account that’s used only for purchases.

  • async-provider ↗

    Ryan Florence released this a few months ago:

    A lightweight, type-safe async context management system for JavaScript applications. Perfect for server-side applications where you need to share request-scoped values across components and functions.

    This is a small wrapper on top of AsyncLocalStorage to provide a simple and type-safe API for request scoped values.

    This is expected to be the recommended solution for type-safe context in upcoming React Router middleware.

    import { createContext, provide, pull } from "@ryanflorence/async-provider";
    
    // 1. ✅ Create your contexts
    let userContext = createContext<User>();
    let dbContext = createContext<Database>();
    
    async function myHandleRequest(req: Request) {
      // setup context values
      let user = await myAuthenticateUser(req);
      let db = myCreateDatabaseConnection(user);
    
      // 2. ✅ Provide contexts
      let html = await provide(
        new Map([
          [userContext, user],
          [dbContext, db],
        ]),
        async () => {
          // run your app code within this context
          let result = await renderApp();
          // Can return values from provider callback
          return result;
        },
      );
    
      return new Response(html, {
        headers: { "Content-Type": "text/html" },
      });
    }
    
    // 3. ✅ Pull context from anywhere
    function renderApp() {
      let user = pull(userContext);
      let db = pull(dbContext);
    
      // Use user and db...
    }

  • New encoding format in Turbo Stream v3 ↗

    Turbo Stream by Jacob Ebey is a streaming data transport for built-in JavaScript features such as Promises, Dates, RegExps, Maps, Sets and more.

    import { decode, encode } from "turbo-stream";
    
    const encodedStream = encode(Promise.resolve(42));
    const decoded = await decode(encodedStream);
    console.log(decoded); // 42

    Turbo Stream powers single-fetch data loaders in React Router which enables streaming Promises from server loaders.

    import type { Route } from "./+types/my-route";
    
    export async function loader({}: Route.LoaderArgs) {
      // note this is NOT awaited
      let nonCriticalData = new Promise((res) =>
        setTimeout(() => res("non-critical"), 5000)
      );
    
      let criticalData = await new Promise((res) =>
        setTimeout(() => res("critical"), 300)
      );
    
      return { nonCriticalData, criticalData };
    }
    

    Turbo Stream v3 is out with support for a new encoding format which supports ReadableStream and many other JS features.

    This means it’ll be coming to React Router very soon. While it’s possible to encode streams into promises, it’ll be good to see React Router support streams natively.