npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@itsmworkbench/dependentdata

v0.3.12

Published

Often some data is dependendent on other data. Needs nuking or reloading when earlier changes

Downloads

1,430

Readme

Dependent Data

This is a constant problem in guis

e.g.

  • I have a list of parameters
  • I have a list of tasks which is dependent on the parameters and one is selected
  • I have a list of services which is dependent on the tasks and the parameters and one is selected

Then

  • When I change the service it's no major impact
  • When I change the task I need to undefined the service and reload the allowed list
  • When I change the parameters I need to undefine the task and service and reload the allowed task

I really want this declarative! Because it's messy. And because I want to be able to do this multiple times in multiple projects

Now we have several aspects to consider problems

  • Expressing it
    • How do we say 'what to do if it's changed
    • How do we express equality?
  • Doing it

Expressing it

  • How do we express the relationship
  • How do we express equality
const paramsI = nameAndStringDI ( lensToParams ) // This told us how to calculate the hash and where the item is
const taskListI = stringArrayDI ( lensToTaskList )
const taskI = string ( lensToTask )
const serviceListI = stringArrayDI ( lensToServiceList )
const serviceI = string ( lensToTask )

dependent ( dis, taskListI, loadTaskList, paramsI ) //so nuke the value if the params change
dependent ( dis, taskI, nuke, taskListI,  paramsI )
dependent ( dis, serviceListI, nuke, taskI )
dependent ( dis, serviceI, loadServiceList, serviceListI ) //skipped the redundancy

Now that is very clean to express the dependencies

BUT!!!

  • how do we say the following
    • the task list should be emptied if the params change, then the list loaded
    • the service list should be emptied if the params or task change, then the list loaded
  • It seems there are multiple concerns
    • What to do if it's changed 'nuke it' being the usual thing
    • Do I have enough information to go and get the data?
    • Should I go and get the data?
    • Other consideration
      • It takes time to fetch data and we don't really want to fetch it twice.
      • It can 'go wrong' when we fetch it. how do we handle those errors
const paramsI = nameAndStringDI ( lensToParams ) // This told us how to calculate the hash and where the item is

function taskListI<S> () { // Can easily have helper methods to make this
  return {
    type: stringArray,
    optional: Optional<S, string[]>,
    dependentOn: paramsI,
    whenUpstreamChanges: 'nuke',
    load: loadTaskList
  }
}

function taskI<S> () {
  return {
    type: string,
    optional: Optional<S, string>,
    dependentOn: [ paramsI, taskListI ],
    whenUpstreamChanges: 'nuke',
    load: undefined
  }
}

function serviceListI<S> () {
  return {
    type: stringArray,
    optional: Optional<S, string[]>,
    dependentOn: [ paramsI, taskListI, taskI ],
    whenUpstreamChanges: 'nuke',
    load: loadServiceList
  }
}

function serviceI<S> () {
  return {
    type: string,
    optional: Optional<S, string>,
    dependentOn: [ serviceListI ],
    whenUpstreamChanges: 'nuke'
  }
}

With helper methods

const paramsI = nameAndStringDI ( lensToParams ) // This told us how to calculate the hash and where the item is
const taskListI = stringArrayDI ( lensToTaskList )
const taskI = string ( lensToTask )
const serviceListI = stringArrayDI ( lensToServiceList )
const serviceI = string ( lensToTask )

loadableDependent ( dis, taskListI, loadTaskList, paramsI ) //so nuke the value if the params change
dependent ( dis, taskI,  taskListI,  paramsI )
loadableDependent ( dis, serviceListI,  taskI )
dependent ( dis, serviceI, loadServiceList, serviceListI ) //skipped the redundancy

Doing it

For the doing it, I think I'll just have the idea of a hash and if the hash changes the value has changed. That hash might be an array of tags or a string...shouldn't really matter.

Clearly we need a dependency tree. Do we need to hierarchically sort it? Or do we just keep changing? Hierarchical sorting is inevitable I think if we have more projects... it allows checks earlier with nicer message. Probably don't need at first.