
Research
/Security News
Shai Hulud Strikes Again (v2)
Another wave of Shai-Hulud campaign has hit npm with more than 500 packages and 700+ versions affected.
@y-block/dom
Advanced tools
The `y-array` component is a custom web component built with Atomico and Yjs. It allows you to bind and observe a Yjs `Y.Array` in a reactive manner, rendering its items dynamically based on provided templates.
The y-array component is a custom web component built with Atomico and Yjs. It allows you to bind and observe a Yjs Y.Array in a reactive manner, rendering its items dynamically based on provided templates.
| Property | Type | Description |
|---|---|---|
| array | Y.Array | A Yjs Array instance to be observed and rendered. |
| Property | Type | Description |
|---|---|---|
| Unassigned | ChildNode | The item template |
If you have an array of strings like this:
doc.getArray('my-array').insert(0, ["Hello", "Array!"])
You can create a component like this:
<y-array array="doc.getArray('my-array')">
<input $:placeholder="item" />
</y-array>
If you have an array of objects, you can create and use the y-array component like this:
doc.getArray('my-array').insert(0, [
{firstName: "Hello", lastName:"Array!", style:{padding: "5px", margin: "5px"}},
{firstName: "So", lastName:"Sweet!", style:{padding: "5px", margin: "5px"}}
])
<y-array array="doc.getArray('my-array')">
<input $:placeholder="firstName" $:style="style" />
<input $:placeholder="lastName" $:style="style" />
</y-array>
The Lazy story demonstrates how to dynamically update the array over time. This example pushes a new item to the array every second.
<script>
const lazyArray = doc.getArray('lazyArray')
lazyArray.push([{ text: "Lazy loading..", idx: 1 }]);
setInterval(() => {
lazyArray.push([{ text: `item ${idx}`, idx: lazyArray.get(lazyArray.length - 1).idx + 1 }]);
}, 1000)
</script>
<y-array array="doc.getArray('lazyArray')">
<input $:placeholder="text"></input>
<input $:placeholder="idx"></input>
</y-array>
1.74 kB | gzip: 0.84 kB
| File | Size | Gzip | lib/index.js 0.10 kB │ gzip: 0.10 kB lib/element.js 1.64 kB │ gzip: 0.74 kB
FAQs
The `y-array` component is a custom web component built with Atomico and Yjs. It allows you to bind and observe a Yjs `Y.Array` in a reactive manner, rendering its items dynamically based on provided templates.
We found that @y-block/dom demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Another wave of Shai-Hulud campaign has hit npm with more than 500 packages and 700+ versions affected.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.