Skip to content

More type safety and idiomatic haxe in README #2

Description

@fullofcaffeine

Some examples in the README are showing this:

@:liveview
class CounterLive {
    var count = 0;
    
    function mount(_params, _session, socket) {
        return {:ok, assign(socket, "count", count)};
    }
    
    function handle_event("increment", _params, socket) {
        count++;
        return {:noreply, assign(socket, "count", count)};
    }
}
  1. This is using plain strings ("count"). We shouldn't be using plain strings or at least they should be typed somehow.
  2. the method arguments are using the _ prefix, which is a common idiom in Elixir, but not sure if we can abstract that away in Haxe? Investigate.

Another case of using plain strings that I should double check:

@:changeset  
class UserChangeset {
    @:validate_required(["name", "email"])
    @:validate_format("email", ~r/\S+@\S+\.\S+/)
    static function changeset(user, attrs) {
        // Compiled to proper Ecto.Changeset pipeline
    }
}

See if there's a better idiomatic Haxe typing strategy that I could use here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions