This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// With Observable | |
@Observable | |
class Book { | |
var title: String | |
var author: String | |
var inStock: Bool | |
init(title: String, author: String, inStock: Bool) { | |
self.title = title |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { subject } from '@webstd/combine'; | |
import type { Publisher } from '@webstd/combine'; | |
import type { Identifiable } from '@webstd/types'; | |
import { element, ReactiveElement, html, environment } from '@webstd/custom-elements'; | |
import { Author } from './author.js' | |
class Book implements Identifiable { | |
id = crypto.randomUUID(); // A unique identifier that never changes. | |
title$ = subject('Sample Book Title'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Observable, ObservationIgnored, withObservationTracking } from '@webstd/observable'; | |
import type { Identifiable } from '@webstd/types'; | |
import { CustomElement, ReactiveElement, html, Environment, State } from '@webstd/custom-elements'; | |
import { stream } from '@webstd/request'; | |
import { Author } from './author.js' | |
@Observable | |
class Book implements Identifiable { | |
@ObservationIgnored id = crypto.randomUUID(); // A unique identifier that never changes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftSignal | |
import FineGrainedViews | |
// Macro usage: | |
final class CounterViewController: UIViewController { | |
private let count = Signal(0) | |
override func viewDidLoad() { | |
super.viewDidLoad() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useSignal } from "@preact/signals" | |
import { action$, island$, json, loader$ } from "preact-server-components" | |
import { useEffect } from "preact/hooks" | |
import { db } from "./db.server" | |
const Counter = island$(() => { | |
let count = useSignal(0) | |
// TODO: Resumable hydration | |
// We don't want to do this work on the server on initial load and then again on |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, State, Computed, html, css } from '@angular/core' | |
import FooDirective from './foo.directive.ts' | |
import FooComponent from './foo.component.ts' | |
// The `selector` is derived from the class's name and a globally configured selector prefix | |
// In this case, the selector for this class would be `app-test`, using the default prefix | |
export class TestComponent implements Component { | |
@State() foo = "" | |
@Computed() get bar(): number { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ===================================================================== | |
// FILE: app/routes/index.route.ts | |
import { Component } from "@angular/core"; | |
import { Paths } from "@remix-run/angular"; | |
import { SidebarListStyle } from "pineappleui"; | |
@Component({ | |
selector: "app-content-view", | |
template: ` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function LandmarkRow({ landmark }) { | |
return ( | |
<HStack> | |
<Image source={landmark.image} resizable /> | |
<Text>{landmark.name}</Text> | |
<Spacer /> | |
</HStack> | |
) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Publisher { | |
@discardableResult | |
func passthrough(_ closure: @escaping (Result<Output, Failure>) -> Void) -> AnyPublisher<Output, Failure> { | |
map { output in | |
closure(.success(output)) | |
return output | |
} | |
.mapError { error in | |
closure(.failure(error)) | |
return error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Combine | |
extension Publisher { | |
var stream: AsyncThrowingStream<Output> { | |
AsyncThrowingStream(Output.self) { continuation in | |
let cancellable = sink { completion in | |
switch completion { | |
case .finished: continuation.finish() | |
case .failure(let error): continuation.finish(throwing: error) | |
} |