Skip to content

Commit

Permalink
Rename controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
sleepyfran committed Aug 31, 2024
1 parent 81e07a2 commit 7a156ea
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions packages/components/add-provider/src/add-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { ProviderLoadedEvent } from "./provider-loader";
import "@echo/components-provider-status";
import "./provider-loader";
import "./select-root";
import { EffectController } from "@echo/components-shared-controllers";
import { EffectConsumer } from "@echo/components-shared-controllers";
import { Match } from "effect";

type ProviderStatus =
Expand All @@ -30,7 +30,7 @@ export class AddProvider extends LitElement {
connectedCallback(): void {
super.connectedCallback();

new EffectController(this, AddProviderWorkflow.availableProviders, {
new EffectConsumer(this, AddProviderWorkflow.availableProviders, {
complete: (availableProviders) => {
this._providerStatus = {
_tag: "ProvidersLoaded",
Expand Down
6 changes: 3 additions & 3 deletions packages/components/add-provider/src/provider-loader.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EffectFnController } from "@echo/components-shared-controllers/src/effect-fn.controller";
import { EffectFn } from "@echo/components-shared-controllers/src/effect-fn.controller";
import {
AddProviderWorkflow,
type FolderMetadata,
Expand Down Expand Up @@ -36,7 +36,7 @@ export class ProviderLoader extends LitElement {
@property({ type: Array })
availableProviders: ProviderMetadata[] = [];

private _loadProvider = new EffectFnController(
private _loadProvider = new EffectFn(
this,
(metadata: ProviderMetadata) => AddProviderWorkflow.loadProvider(metadata),
{
Expand All @@ -46,7 +46,7 @@ export class ProviderLoader extends LitElement {
},
);

private _connectToProvider = new EffectFnController(
private _connectToProvider = new EffectFn(
this,
() => AddProviderWorkflow.connectToProvider,
{
Expand Down
4 changes: 2 additions & 2 deletions packages/components/add-provider/src/select-root.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EffectFnController } from "@echo/components-shared-controllers/src/effect-fn.controller";
import { EffectFn } from "@echo/components-shared-controllers/src/effect-fn.controller";
import { AddProviderWorkflow, type FolderMetadata } from "@echo/core-types";
import { LitElement, html, nothing } from "lit";
import { customElement, property } from "lit/decorators.js";
Expand All @@ -22,7 +22,7 @@ export class SelectRoot extends LitElement {
@property({ type: Array })
availableFolders: FolderMetadata[] = [];

private _selectRoot = new EffectFnController(
private _selectRoot = new EffectFn(
this,
(rootFolder: FolderMetadata) => AddProviderWorkflow.selectRoot(rootFolder),
{
Expand Down
8 changes: 4 additions & 4 deletions packages/components/library/src/user-library.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { StreamEffectController } from "@echo/components-shared-controllers";
import { EffectFnController } from "@echo/components-shared-controllers/src/effect-fn.controller";
import { StreamConsumer } from "@echo/components-shared-controllers";
import { EffectFn } from "@echo/components-shared-controllers/src/effect-fn.controller";
import { Library, Player } from "@echo/core-types";
import { LitElement, html } from "lit";
import { customElement } from "lit/decorators.js";
Expand All @@ -11,8 +11,8 @@ import { map } from "lit/directives/map.js";
*/
@customElement("user-library")
export class UserLibrary extends LitElement {
private _library = new StreamEffectController(this, Library.observeAlbums);
private _playAlbum = new EffectFnController(this, Player.playAlbum);
private _library = new StreamConsumer(this, Library.observeAlbums);
private _playAlbum = new EffectFn(this, Player.playAlbum);

render() {
return this._library.render({
Expand Down
4 changes: 2 additions & 2 deletions packages/components/provider-status/src/provider-status.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MediaProviderStatus } from "@echo/core-types";
import { StreamEffectController } from "@echo/components-shared-controllers";
import { StreamConsumer } from "@echo/components-shared-controllers";
import { LitElement, html } from "lit";
import { customElement } from "lit/decorators.js";
import { map } from "lit/directives/map.js";
Expand All @@ -9,7 +9,7 @@ import { map } from "lit/directives/map.js";
*/
@customElement("provider-status")
export class ProviderStatus extends LitElement {
private _providerStatus = new StreamEffectController(
private _providerStatus = new StreamConsumer(
this,
MediaProviderStatus.observe,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type StreamStatus<A, E> =
* Controller that takes a function that produces an effect and exposes a
* method to execute the effect and render the different states of the effect.
*/
export class EffectFnController<P, A, E> implements ReactiveController {
export class EffectFn<P, A, E> implements ReactiveController {
private host: ReactiveControllerHost;
private _status: StreamStatus<A, E> = { _tag: "Initial" };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import { type EchoRuntimeServices } from "@echo/services-bootstrap-runtime";
import { Effect } from "effect";
import type { ReactiveControllerHost } from "lit";
import type { StatusListener } from "./shared.interface";
import { EffectFnController } from "./effect-fn.controller";
import { EffectFn } from "./effect-fn.controller";

/**
* Controller that takes an effect that can be executed by the default runtime
* of the application, and exposes a render method that maps each different
* status of the effect to a renderer. This is meant to be used with effects
* that are one-shot, meaning they only produce a single value. For multiple
* values, use the StreamEffectController, which can handle streams and
* values, use the StreamConsumer, which can handle streams and
* subscription refs.
*/
export class EffectController<A, E> extends EffectFnController<void, A, E> {
export class EffectConsumer<A, E> extends EffectFn<void, A, E> {
constructor(
host: ReactiveControllerHost,
_effect: Effect.Effect<A, E, EchoRuntimeServices>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type OutputEffect<A, E> = Effect.Effect<
* and exposes a render method that renders maps the different states of the
* stream to a renderer.
*/
export class StreamEffectController<A, E> implements ReactiveController {
export class StreamConsumer<A, E> implements ReactiveController {
private host: ReactiveControllerHost;
private _status: StreamStatus<A, E> = { _tag: "Initial" };

Expand Down
4 changes: 2 additions & 2 deletions packages/web/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { LitElement, html } from "lit";
import { customElement } from "lit/decorators.js";
import { initializeWorkers } from "@echo/services-bootstrap-workers";
import { AppInit } from "@echo/core-types";
import { EffectController } from "@echo/components-shared-controllers";
import { EffectConsumer } from "@echo/components-shared-controllers";
import "@echo/components-add-provider";
import "@echo/components-library";

Expand All @@ -13,7 +13,7 @@ initializeWorkers();
*/
@customElement("app-root")
export class MyElement extends LitElement {
private _init = new EffectController(this, AppInit.init);
private _init = new EffectConsumer(this, AppInit.init);

render() {
return this._init.render({
Expand Down

0 comments on commit 7a156ea

Please sign in to comment.