🌊
jsf
  • About KalmiaJSF
  • Setup
  • Architecture
  • Contributing
  • Changelog
  • Guides
    • Cheat Sheet
  • Examples
    • Demo example
    • Basic examples
    • Kitchen Sink example
    • Charts example
  • Schema
    • Intro to Schema
    • Prop types
      • String
      • Boolean
      • Number & Integer
      • Object
      • Array
      • Date
      • Id
      • Null
      • Ref
      • Binary
    • Prop options
      • Disabling property
      • On prop init actions
      • Persist
      • On value change
      • On user value change
    • Handlers
      • Color picker
    • Creating custom handler
      • Working with arrays
    • Value provider
  • Validation
    • Custom validation
    • Eval
  • LAYOUT
    • Intro to Layout
    • Layout options
      • Show & hide
      • On click action
  • INTERFACES
    • Value Options
  • Form
    • Form data
  • OTHER
    • Events
    • Lifecycle hooks
    • Notifications support
  • PAGES & COMPONENTS
    • Page
    • Component
  • THEMING
    • Creating new theme variant
  • BUILDER
    • Shortcuts
  • Help
    • FAQ
Powered by GitBook
On this page

Was this helpful?

Export as PDF
  1. Schema
  2. Creating custom handler

Working with arrays

In order to know when items change in array you can subscribe to events. Array prop builder supports following observables:

  • onItemAdd - called when new item is added.

  • onItemRemove - called when item is removed.

  • onItemsSet - called when setValue or setJsonValue is called.

All prob builders also provide observable:

  • valueChange(): Observable<ValueChangeInterface>

Observable will emit value every time value is change, exception is only if setValue is called with silent option.

  • get statusChange(): Observable<PropStatus>

Observable will emit status every tiem status is changed (VALID, INVALID, PENDING, DISABLED). Please note this can happen at any moment since it is controled by JSF resolver.

Example usage from core table layout

this.propBuilder.onItemsSet
  .pipe(takeUntil(this.ngUnsubscribe))
  .subscribe(() => {
    this.detectChanges();
  });

this.propBuilder.onItemAdd
  .pipe(takeUntil(this.ngUnsubscribe))
  .subscribe(() => {
    this.detectChanges();
  });

this.propBuilder.onItemRemove
  .pipe(takeUntil(this.ngUnsubscribe))
  .subscribe(() => {
    this.detectChanges();
  });
PreviousCreating custom handlerNextValue provider

Last updated 4 years ago

Was this helpful?