Question: exposing computed values from protocols

I have a NPL protocol called PurchaseOrder with a function total() returns Number -> quantity * unitPrice. When I GET the protocol instance, total isn’t in the response, only constructor params and var declarations.

Currently I’m creating @api permission getTotal() for each computed value, then calling them separately. Is there a better pattern? Feels like a lot of boilerplate for derived fields.

Hi @jk-nd

This is indeed the usual pattern; the notion of read-only derived values has been brought up before, but we’re still considering the various approaches for this.

1 Like