guisehn

guisehn

Phoenix_typed_hook - better documentation and autocomplete for Phoenix LiveView client hooks

The combination of Elixir typespecs with @doc allows Phoenix to provide great documentation and autocompletion inside the code editor. But I missed the same level of good experience when playing with LiveView client hooks via phx-hook.

Since LiveView hooks are defined as plain JS objects, there is no way for code editors to provide documentation and autocomplete around attributes and callbacks available, nor compile-time checks (this last one, when TypeScript is used in the project).

To solve that, I created a tiny library called phoenix_typed_hook, that allows you to define a LiveView client hook by extending a base typed Hook class. By using it, editors like VS Code will provide all those documentation and autocomplete features automatically. And there is no need to use TypeScript in the project to take advantage of it, if it’s not your thing.

One GIF says more than a thousand words. :slight_smile:

It can be installed through Hex or NPM.

Hope you find it useful!

Links:

Most Liked

zachallaun

zachallaun

This is awesome! I see that you’ve released it as v0.18 as well, which is smart. Should make upgrades nice and easy!

One suggestion, if I may: I believe it should be possible to distribute this through Hex so that it can be added to your mix.exs dependencies. This would also make it very easy to remember to upgrade down the line. Here’s an example of a project that bundles some JS. It looks like the minified JS is included in the list of files in package. I don’t think there’s any particular reason that

guisehn

guisehn

Nice suggestion! I’ve released it to Hex as well and updated the initial post. :slight_smile:

Note: when installing it through Hex, it’s still necessary to add it to package.json but pointing to the Hex-downloaded code inside deps, to make the code editor detect the typing to provide autocomplete.

Where Next?

Popular in Libraries Top

markmark206
simple_feature_flags is a tiny package that lets you turn features on or off based on which environment (e.g. localhost, staging, product...
New
OvermindDL1
Been making an MLElixir thing (not released yet…) for fun in spare time in the past day. I’m just trying to see how much I can get an ML...
132 13487 106
New
wfgilman
I’ve cleaned up and open sourced three financial libraries I was using for my company. They are bindings for the APIs of these three comp...
New
Qqwy
Solution is a library to help you with working with ok/error-tuples in case and with-expressions by exposing special matching macros, as ...
New
martinthenth
Hello everybody :wave: Recently, some of my colleagues talked about database ids and uuids and their problems, and I remembered the pain...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 27727 240
New
gabrielpoca
Hello everyone! I want to share with you something that I’m really proud of: https://stillstatic.io/ Still is a static site builder for...
New
handnot2
Samly can be used to enable SAML 2.0 Single Sign On in a Plug/Phoenix application. This library uses Erlang esaml to provide plug enabl...
New
KallDrexx
For a good number of months I've been working on creating a very basic RTMP live video streaming server. Now that I have a very, very ba...
New
anshuman23
Hello all, I have been working on my proposed project called Tensorflex as part of Google Summer of Code 2018.. Tensorflex can be used f...
New

Other popular topics Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 45766 226
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

Sub Categories:

We're in Beta

About us Mission Statement