Skip to content

Instantly share code, notes, and snippets.

@Brian-McBride
Brian-McBride / executor.ts
Created December 14, 2023 18:41
Nx using Astro Advanced APIs (Build)
import { writeFileSync } from 'fs';
import { resolve } from 'path';
import type { ExecutorContext } from '@nx/devkit';
import {
logger,
stripIndents,
writeJsonFile,
detectPackageManager,
} from '@nx/devkit';
import { createLockFile, createPackageJson, getLockFileName } from '@nx/js';
@Brian-McBride
Brian-McBride / example.ts
Created June 21, 2023 18:20
React Query with XState
export function useStateHook() {
const machineRef = useActorRef(userStateMachine);
const result = trpcReact.user.getById.useQuery('someUserId', {
onSettled(data, error) {
if (error) {
machineRef.send({
type: 'FETCH_ERROR',
error,
});
@Brian-McBride
Brian-McBride / README.md
Last active June 9, 2023 20:23
XState Actor Manager

Actor Manager

The goal here is to be able to dynamically add and spawn actors within xstate.

Items of Note

  • The id provdied will be the one that resolved on the system object for system.get(id) calls from other actors.
  • There isn't a lot of garbage colleciton or the concept of removing actors yet
  • This probably works best with other full state machines
  • Sending a message to a machine not spawed isn't captured or buffered in any way. The event errors or is lost.
@Brian-McBride
Brian-McBride / firebase-admin-jest-nx.md
Last active October 18, 2021 15:45
firebase-admin v10 with Jest 27 inside @nrwl/nx monorepo

firebase-admin + jest + nx

Using the new v10 firebase-admin libs with Jest v27 and Nx monorepos

Problem

Jest does not support the exports keyword within package.json fully. Proper support is expected in Jest 28

Will solve this error when updating to the new firebase-admin import methods

04423751241947fb9591458093d5dbd427d23f7eceef01d613df04ac4486eff0e4af8b2f5a246b13acd352e8c5f0f2b78c130197d4323f3e3eed71c39ef964c005
@Brian-McBride
Brian-McBride / Feathers-ArangoDB-Connector.md
Last active February 15, 2020 18:53
Feathers-ArangoDB

This is a start to get ArangoDB as a connector for FeathersJS

Dependencies

You'll need a few npm packages.

yarn add arangojs
yarn add uuid
yarn add clone-deep
@Brian-McBride
Brian-McBride / FeathersJS-Swagger-Validation.md
Last active January 16, 2018 22:30
Using swagger yaml files for validation in FeathersJS

This process will allow you to use Swagger Yaml files for validation. I've only tried this with REST endpoints, however it seems this should work with real-time sockets as well.

Dependencies

You'll need a few npm packages.

yarn add swagger-tools
var _ = require('/lib/underscore');
/*
*This is the lightweight version I use based on Kevin Whinnery's one: https://gist.github.com/kwhinnery/1595307
* Wrapper for Titanium UI components. This wrapper provides a few pieces of critical
* functionality, currently missing from Titanium UI objects:
* - The ability to safely extend components with new members
* - Rudimentary resource management and object lifecycle handling
*