From f612273632d92d98eea3563f0e5e14121fdae9bf Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Thu, 25 Nov 2021 10:05:07 +0100 Subject: [PATCH] Rename bind to bindContent in listener.js This is partly to avoid confusion with the skooma `bind` function, but also to make it clearer that only the inner content of an element is being bound to the listener. This function may also disappear entirely in the future if it turns out it doesn't provide any benefits over the skooma bind function. --- listener.js | 2 +- listener.md | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/listener.js b/listener.js index 24c4ed7..e64d682 100644 --- a/listener.js +++ b/listener.js @@ -39,7 +39,7 @@ export const listener = (target={}) => { return proxy } -export const bind = (listener, prop, target=document.createTextNode(""), filter) => { +export const bindContent = (listener, prop="value", target=document.createTextNode(""), filter) => { const run = data => { data = filter ? filter(data) diff --git a/listener.md b/listener.md index 3d31336..b3e6719 100644 --- a/listener.md +++ b/listener.md @@ -16,17 +16,20 @@ listener.listen(prop) ``` ```js -bind(listener, "value") +bindContent(listener, "value") // Returns a text node with listener.value as its content // that will change whenever the value is changed -bind(listener, "value", html_element) +bindContent(listener, "value", html_element) // Binds an existng HTML or Text node -bind(listener, "value", html_element, value => value.toUpperCase()) +bindContent(listener, "value", html_element, value => value.toUpperCase()) // Accepts a function to transform the value -bind(listener, "value", html_element, value => document.createElement("hr")) +bindContent(listener, "value", html_element, value => document.createElement("hr")) // Also accepts HTML elements when the target is not a text node ``` +This function *may* be **removed** in the future if it doesn't show any +usefullnes that isn't already provided by the skooma bind function. + ## Example ```js