Skip to content

ember-resources@6.1.0

Compare
Choose a tag to compare
@github-actions github-actions released this 26 Apr 04:28
· 547 commits to main since this release
5ada957

Minor Changes

  • #866 e1e4f66 Thanks @NullVoxPopuli! - Add the ability to compose function resources.
    This is enabled only for function resources as class-based resources could already compose.

    how function resources compose
    let formatter = new Intl.DateTimeFormat("en-US", {
      hour: "numeric",
      minute: "numeric",
      second: "numeric",
      hour12: false,
    });
    
    let format = (time) => formatter.format(time.current);
    
    // representing the current time.
    // This could be rendered directly as {{Now}}
    // but Date does not serialize nicely for humans (Date.now() is a number)
    const Now = resource(({ on }) => {
      let now = cell(Date.now());
      let timer = setInterval(() => now.set(Date.now()), 1000);
    
      on.cleanup(() => clearInterval(timer));
    
      return () => now.current;
    });
    
    const Clock = resource(({ use }) => {
      let time = use(Now);
    
      return () => format(time);
    });
    
    // Rendered, Clock is always the formatted time
    <template>
      <time>{{ Clock }}</time>
    </template>;

Patch Changes

  • #829 ff776b1 Thanks @NullVoxPopuli! - Move ember-async-data to "dependencies" because users are not required to import from that package ever"